using Circus.CodeEditor;
using Circus.Syntax.Lexer;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Circus.Syntax.Design.Dialogs
{
	public class DlgSyntaxBuilder : Form
	{
		internal enum NodeKind
		{
			nkNone,
			nkStyles,
			nkStyle,
			nkStates,
			nkState,
			nkSyntaxBlock,
			nkGeneral,
			nkreswordSet
		}
		private const int cOpenFolder = 0;
		private const int cCloseFolder = 1;
		private const int cSelItem = 2;
		private const int cUnSelItem = 3;
		private const int cState = 4;
		private Panel pnButtons;
		private Button btClear;
		private Button btSave;
		private TreeView tvLexer;
		private IContainer components;
		private Button btLoadScheme;
		private ImageList imLexer;
		private Button btOk;
		private Button btCancel;
		private TabControl tcPanels;
		private TabPage tpGeneral;
		private TabPage tpStyles;
		private TabPage tpStates;
		public Panel pnStyles;
		public Panel pnStates;
		public Panel pnGeneral;
		public Label laCopyright;
		public Label laDescription;
		public Label laSchemeName;
		public Label laAuthor;
		public TextBox tbCopyright;
		public TextBox tbDescription;
		public TextBox tbSchemeName;
		public TextBox tbAuthor;
		private Panel pnMain;
		private SaveFileDialog saveFileDialog;
		private OpenFileDialog openFileDialog;
		private ImageList ilButtons;
		public Label laFileType;
		public TextBox tbFileType;
		public Label laFileExt;
		private Button btMoveUpStyle;
		private Button btRemoveStyle;
		private Button btAddStyle;
		private ListBox lbStyles;
		private Button btMoveDownStyle;
		private ImageList imButtons;
		private Button btMoveDownState;
		private Button btMoveUpState;
		private Button btRemoveState;
		private Button btAddState;
		private ListBox lbStates;
		private GroupBox gbStates;
		private GroupBox gbStyles;
		private TabPage tpStyle;
		private TabPage tpState;
		private TabPage tpSyntaxBlock;
		private TabPage tpReswordSet;
		public Panel pnStyle;
		public Panel pnSample;
		public Label laSample;
		public GroupBox gbStyleProperties;
		public CheckBox chbPlainText;
		public TextBox tbStyleName;
		public Label laStyleName;
		public Label laStyleBkColor;
		public Label laStyleForeColor;
		public TextBox tbStyleDesc;
		public Label laStyleDesc;
		public ColorBox clbBkColor;
		public ColorBox clbForeColor;
		public GroupBox gbFontStyles;
		public CheckBox chbStrikeout;
		public CheckBox chbItalic;
		public CheckBox chbUnderline;
		public CheckBox chbBold;
		private Panel pnState;
		public GroupBox gbStateProperties;
		public TextBox tbStateName;
		private Label laStateName;
		public Label laStateDesc;
		public TextBox tbStateDesc;
		public CheckBox chbCaseSensitive;
		private Panel pnSyntaxBlock;
		public GroupBox gbSyntaxBlockProperties;
		public TextBox tbExpressions;
		private TextBox tbBlockName;
		private Label laBlockName;
		public Label laBlockExpr;
		public TextBox tbBlockDesc;
		public Label laBlockDesc;
		public Label laLeaveState;
		public Label laStyle;
		public ComboBox cbLeaveState;
		public ComboBox cbStyle;
		private Panel pnReswordSet;
		private GroupBox gbreswordsProperties;
		private TextBox tbreswordSetName;
		private Label lareswordSetName;
		public ComboBox cbreswordStyle;
		public TextBox tbreswords;
		public Label laBlockreswords;
		public Label lareswordStyle;
		private GroupBox gbSyntaxBlocks;
		private ListBox lbSyntaxBlocks;
		private Button btAddBlock;
		private Button btRemoveBlock;
		private Button btMoveDownBlock;
		private Button btMoveUpBlock;
		private GroupBox gbReswordSets;
		private ListBox lbReswordSets;
		private Button btAddReswordSet;
		private Button btRemoveReswordSet;
		private Button btMoveDownReswordSet;
		private Button btMoveUpReswordSet;
		public TextBox tbFileExt;
        private Circus.Syntax.Lexer.Lexer lexer;
		private bool updating = false;
		private TreeNode rootNode;
		private TreeNode stylesNode;
		private TreeNode statesNode;
		private int cDefaultHeight = 420;
		private int cDefaultWidth = 572;
		private string sRemoveScroll = new string('x', 100);
		public LexScheme Scheme
		{
			get
			{
				return this.lexer.Scheme;
			}
			set
			{
				this.lexer.Scheme = value;
				this.UpdateScheme();
			}
		}
		public DlgSyntaxBuilder()
		{
			this.InitializeComponent();
			this.lexer = new Circus.Syntax.Lexer.Lexer();
			this.rootNode = this.tvLexer.Nodes[0];
			this.stylesNode = this.rootNode.Nodes[0];
			this.statesNode = this.rootNode.Nodes[1];
		}
		public DlgSyntaxBuilder(SyntaxBuilderEditor editor) : this()
		{
			base.StartPosition = FormStartPosition.CenterScreen;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.TopLevel = true;
			base.ShowInTaskbar = false;
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (this.components != null)
				{
					this.components.Dispose();
				}
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.components = new Container();
			TreeNode treeNode = new TreeNode("Styles", 1, 0);
			TreeNode treeNode2 = new TreeNode("States", 1, 0);
			TreeNode treeNode3 = new TreeNode("Syntax Scheme Editor", 0, 0, new TreeNode[]
			{
				treeNode,
				treeNode2
			});
			ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof(DlgSyntaxBuilder));
			this.pnButtons = new Panel();
			this.btCancel = new Button();
			this.btOk = new Button();
			this.btLoadScheme = new Button();
			this.btClear = new Button();
			this.btSave = new Button();
			this.tvLexer = new TreeView();
			this.imLexer = new ImageList(this.components);
			this.pnMain = new Panel();
			this.tcPanels = new TabControl();
			this.tpGeneral = new TabPage();
			this.pnGeneral = new Panel();
			this.laFileExt = new Label();
			this.tbFileExt = new TextBox();
			this.laFileType = new Label();
			this.tbFileType = new TextBox();
			this.laCopyright = new Label();
			this.laDescription = new Label();
			this.laSchemeName = new Label();
			this.laAuthor = new Label();
			this.tbCopyright = new TextBox();
			this.tbDescription = new TextBox();
			this.tbSchemeName = new TextBox();
			this.tbAuthor = new TextBox();
			this.tpStyles = new TabPage();
			this.pnStyles = new Panel();
			this.gbStyles = new GroupBox();
			this.lbStyles = new ListBox();
			this.btRemoveStyle = new Button();
			this.btMoveDownStyle = new Button();
			this.imButtons = new ImageList(this.components);
			this.btAddStyle = new Button();
			this.btMoveUpStyle = new Button();
			this.tpStates = new TabPage();
			this.pnStates = new Panel();
			this.gbStates = new GroupBox();
			this.lbStates = new ListBox();
			this.btAddState = new Button();
			this.btRemoveState = new Button();
			this.btMoveDownState = new Button();
			this.btMoveUpState = new Button();
			this.tpStyle = new TabPage();
			this.pnStyle = new Panel();
			this.pnSample = new Panel();
			this.laSample = new Label();
			this.gbStyleProperties = new GroupBox();
			this.chbPlainText = new CheckBox();
			this.tbStyleName = new TextBox();
			this.laStyleName = new Label();
			this.laStyleBkColor = new Label();
			this.laStyleForeColor = new Label();
			this.tbStyleDesc = new TextBox();
			this.laStyleDesc = new Label();
			this.clbBkColor = new ColorBox(this.components);
			this.clbForeColor = new ColorBox(this.components);
			this.gbFontStyles = new GroupBox();
			this.chbStrikeout = new CheckBox();
			this.chbItalic = new CheckBox();
			this.chbUnderline = new CheckBox();
			this.chbBold = new CheckBox();
			this.tpState = new TabPage();
			this.pnState = new Panel();
			this.gbSyntaxBlocks = new GroupBox();
			this.lbSyntaxBlocks = new ListBox();
			this.btAddBlock = new Button();
			this.btRemoveBlock = new Button();
			this.btMoveDownBlock = new Button();
			this.btMoveUpBlock = new Button();
			this.gbStateProperties = new GroupBox();
			this.tbStateName = new TextBox();
			this.laStateName = new Label();
			this.laStateDesc = new Label();
			this.tbStateDesc = new TextBox();
			this.chbCaseSensitive = new CheckBox();
			this.tpSyntaxBlock = new TabPage();
			this.pnSyntaxBlock = new Panel();
			this.gbReswordSets = new GroupBox();
			this.lbReswordSets = new ListBox();
			this.btAddReswordSet = new Button();
			this.btRemoveReswordSet = new Button();
			this.btMoveDownReswordSet = new Button();
			this.btMoveUpReswordSet = new Button();
			this.gbSyntaxBlockProperties = new GroupBox();
			this.tbExpressions = new TextBox();
			this.tbBlockName = new TextBox();
			this.laBlockName = new Label();
			this.laBlockExpr = new Label();
			this.tbBlockDesc = new TextBox();
			this.laBlockDesc = new Label();
			this.laLeaveState = new Label();
			this.laStyle = new Label();
			this.cbLeaveState = new ComboBox();
			this.cbStyle = new ComboBox();
			this.tpReswordSet = new TabPage();
			this.pnReswordSet = new Panel();
			this.gbreswordsProperties = new GroupBox();
			this.tbreswordSetName = new TextBox();
			this.lareswordSetName = new Label();
			this.cbreswordStyle = new ComboBox();
			this.tbreswords = new TextBox();
			this.laBlockreswords = new Label();
			this.lareswordStyle = new Label();
			this.ilButtons = new ImageList(this.components);
			this.saveFileDialog = new SaveFileDialog();
			this.openFileDialog = new OpenFileDialog();
			this.pnButtons.SuspendLayout();
			this.pnMain.SuspendLayout();
			this.tcPanels.SuspendLayout();
			this.tpGeneral.SuspendLayout();
			this.pnGeneral.SuspendLayout();
			this.tpStyles.SuspendLayout();
			this.pnStyles.SuspendLayout();
			this.gbStyles.SuspendLayout();
			this.tpStates.SuspendLayout();
			this.pnStates.SuspendLayout();
			this.gbStates.SuspendLayout();
			this.tpStyle.SuspendLayout();
			this.pnStyle.SuspendLayout();
			this.pnSample.SuspendLayout();
			this.gbStyleProperties.SuspendLayout();
			this.gbFontStyles.SuspendLayout();
			this.tpState.SuspendLayout();
			this.pnState.SuspendLayout();
			this.gbSyntaxBlocks.SuspendLayout();
			this.gbStateProperties.SuspendLayout();
			this.tpSyntaxBlock.SuspendLayout();
			this.pnSyntaxBlock.SuspendLayout();
			this.gbReswordSets.SuspendLayout();
			this.gbSyntaxBlockProperties.SuspendLayout();
			this.tpReswordSet.SuspendLayout();
			this.pnReswordSet.SuspendLayout();
			this.gbreswordsProperties.SuspendLayout();
			base.SuspendLayout();
			this.pnButtons.BackColor = SystemColors.Control;
			this.pnButtons.BorderStyle = BorderStyle.Fixed3D;
			this.pnButtons.Controls.Add(this.btCancel);
			this.pnButtons.Controls.Add(this.btOk);
			this.pnButtons.Controls.Add(this.btLoadScheme);
			this.pnButtons.Controls.Add(this.btClear);
			this.pnButtons.Controls.Add(this.btSave);
			this.pnButtons.Dock = DockStyle.Bottom;
			this.pnButtons.Location = new Point(0, 380);
			this.pnButtons.Name = "pnButtons";
			this.pnButtons.Size = new Size(590, 40);
			this.pnButtons.TabIndex = 12;
			this.btCancel.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.btCancel.DialogResult = DialogResult.Cancel;
			this.btCancel.Location = new Point(508, 10);
			this.btCancel.Name = "btCancel";
			this.btCancel.Size = new Size(75, 23);
			this.btCancel.TabIndex = 33;
			this.btCancel.Text = "Cancel";
			this.btCancel.Click += new EventHandler(this.btCancel_Click);
			this.btOk.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.btOk.DialogResult = DialogResult.OK;
			this.btOk.Location = new Point(428, 10);
			this.btOk.Name = "btOk";
			this.btOk.Size = new Size(75, 23);
			this.btOk.TabIndex = 32;
			this.btOk.Text = "&OK";
			this.btOk.Click += new EventHandler(this.btOk_Click);
			this.btLoadScheme.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.btLoadScheme.Location = new Point(172, 10);
			this.btLoadScheme.Name = "btLoadScheme";
			this.btLoadScheme.Size = new Size(75, 23);
			this.btLoadScheme.TabIndex = 28;
			this.btLoadScheme.Text = "Load";
			this.btLoadScheme.Click += new EventHandler(this.btLoadScheme_Click);
			this.btClear.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.btClear.Location = new Point(332, 10);
			this.btClear.Name = "btClear";
			this.btClear.Size = new Size(75, 23);
			this.btClear.TabIndex = 31;
			this.btClear.Text = "Clear";
			this.btClear.Click += new EventHandler(this.btClear_Click);
			this.btSave.Anchor = (AnchorStyles.Top | AnchorStyles.Right);
			this.btSave.Location = new Point(252, 10);
			this.btSave.Name = "btSave";
			this.btSave.Size = new Size(75, 23);
			this.btSave.TabIndex = 29;
			this.btSave.Text = "Save";
			this.btSave.Click += new EventHandler(this.btSave_Click);
			this.tvLexer.BackColor = SystemColors.Control;
			this.tvLexer.Dock = DockStyle.Left;
			this.tvLexer.HideSelection = false;
			this.tvLexer.ImageIndex = 3;
			this.tvLexer.ImageList = this.imLexer;
			this.tvLexer.Location = new Point(0, 0);
			this.tvLexer.Name = "tvLexer";
			treeNode.ImageIndex = 1;
			treeNode.Name = "";
			treeNode.SelectedImageIndex = 0;
			treeNode.Text = "Styles";
			treeNode2.ImageIndex = 1;
			treeNode2.Name = "";
			treeNode2.SelectedImageIndex = 0;
			treeNode2.Text = "States";
			treeNode3.ImageIndex = 0;
			treeNode3.Name = "";
			treeNode3.SelectedImageIndex = 0;
			treeNode3.Text = "Syntax Scheme Editor";
			this.tvLexer.Nodes.AddRange(new TreeNode[]
			{
				treeNode3
			});
			this.tvLexer.SelectedImageIndex = 2;
			this.tvLexer.ShowLines = false;
			this.tvLexer.ShowRootLines = false;
			this.tvLexer.Size = new Size(184, 380);
			this.tvLexer.TabIndex = 34;
			this.tvLexer.AfterCollapse += new TreeViewEventHandler(this.tvLexer_AfterCollapse);
			this.tvLexer.AfterSelect += new TreeViewEventHandler(this.tvLexer_AfterSelect);
			this.tvLexer.MouseDown += new MouseEventHandler(this.tvLexer_MouseDown);
			this.tvLexer.BeforeLabelEdit += new NodeLabelEditEventHandler(this.tvLexer_BeforeLabelEdit);
			this.tvLexer.AfterExpand += new TreeViewEventHandler(this.tvLexer_AfterExpand);
			this.imLexer.ImageStream = (ImageListStreamer)componentResourceManager.GetObject("imLexer.ImageStream");
			this.imLexer.TransparentColor = Color.Red;
			this.imLexer.Images.SetKeyName(0, "");
			this.imLexer.Images.SetKeyName(1, "");
			this.imLexer.Images.SetKeyName(2, "");
			this.imLexer.Images.SetKeyName(3, "");
			this.imLexer.Images.SetKeyName(4, "");
			this.pnMain.BackColor = SystemColors.Control;
			this.pnMain.Controls.Add(this.tcPanels);
			this.pnMain.Dock = DockStyle.Fill;
			this.pnMain.Location = new Point(184, 0);
			this.pnMain.Name = "pnMain";
			this.pnMain.Size = new Size(406, 380);
			this.pnMain.TabIndex = 35;
			this.tcPanels.Controls.Add(this.tpGeneral);
			this.tcPanels.Controls.Add(this.tpStyles);
			this.tcPanels.Controls.Add(this.tpStates);
			this.tcPanels.Controls.Add(this.tpStyle);
			this.tcPanels.Controls.Add(this.tpState);
			this.tcPanels.Controls.Add(this.tpSyntaxBlock);
			this.tcPanels.Controls.Add(this.tpReswordSet);
			this.tcPanels.Location = new Point(0, 0);
			this.tcPanels.Name = "tcPanels";
			this.tcPanels.SelectedIndex = 0;
			this.tcPanels.Size = new Size(400, 370);
			this.tcPanels.TabIndex = 0;
			this.tcPanels.Visible = false;
			this.tpGeneral.BackColor = Color.Transparent;
			this.tpGeneral.Controls.Add(this.pnGeneral);
			this.tpGeneral.Location = new Point(4, 22);
			this.tpGeneral.Name = "tpGeneral";
			this.tpGeneral.Size = new Size(392, 344);
			this.tpGeneral.TabIndex = 0;
			this.tpGeneral.Text = "General";
			this.pnGeneral.BackColor = Color.Transparent;
			this.pnGeneral.Controls.Add(this.laFileExt);
			this.pnGeneral.Controls.Add(this.tbFileExt);
			this.pnGeneral.Controls.Add(this.laFileType);
			this.pnGeneral.Controls.Add(this.tbFileType);
			this.pnGeneral.Controls.Add(this.laCopyright);
			this.pnGeneral.Controls.Add(this.laDescription);
			this.pnGeneral.Controls.Add(this.laSchemeName);
			this.pnGeneral.Controls.Add(this.laAuthor);
			this.pnGeneral.Controls.Add(this.tbCopyright);
			this.pnGeneral.Controls.Add(this.tbDescription);
			this.pnGeneral.Controls.Add(this.tbSchemeName);
			this.pnGeneral.Controls.Add(this.tbAuthor);
			this.pnGeneral.Location = new Point(0, 0);
			this.pnGeneral.Name = "pnGeneral";
			this.pnGeneral.Size = new Size(380, 340);
			this.pnGeneral.TabIndex = 1;
			this.pnGeneral.Visible = false;
			this.laFileExt.AutoSize = true;
			this.laFileExt.Location = new Point(16, 256);
			this.laFileExt.Name = "laFileExt";
			this.laFileExt.Size = new Size(75, 13);
			this.laFileExt.TabIndex = 10;
			this.laFileExt.Text = "File Extension:";
			this.tbFileExt.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.tbFileExt.Location = new Point(16, 280);
			this.tbFileExt.Name = "tbFileExt";
			this.tbFileExt.Size = new Size(356, 20);
			this.tbFileExt.TabIndex = 11;
			this.tbFileExt.TextChanged += new EventHandler(this.tbFileExt_TextChanged);
			this.laFileType.AutoSize = true;
			this.laFileType.Location = new Point(16, 202);
			this.laFileType.Name = "laFileType";
			this.laFileType.Size = new Size(53, 13);
			this.laFileType.TabIndex = 8;
			this.laFileType.Text = "File Type:";
			this.tbFileType.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.tbFileType.Location = new Point(16, 226);
			this.tbFileType.Name = "tbFileType";
			this.tbFileType.Size = new Size(356, 20);
			this.tbFileType.TabIndex = 9;
			this.tbFileType.TextChanged += new EventHandler(this.tbFileType_TextChanged);
			this.laCopyright.AutoSize = true;
			this.laCopyright.Location = new Point(16, 152);
			this.laCopyright.Name = "laCopyright";
			this.laCopyright.Size = new Size(54, 13);
			this.laCopyright.TabIndex = 6;
			this.laCopyright.Text = "Copyright:";
			this.laDescription.AutoSize = true;
			this.laDescription.Location = new Point(16, 104);
			this.laDescription.Name = "laDescription";
			this.laDescription.Size = new Size(63, 13);
			this.laDescription.TabIndex = 4;
			this.laDescription.Text = "Description:";
			this.laSchemeName.AutoSize = true;
			this.laSchemeName.Location = new Point(16, 56);
			this.laSchemeName.Name = "laSchemeName";
			this.laSchemeName.Size = new Size(80, 13);
			this.laSchemeName.TabIndex = 2;
			this.laSchemeName.Text = "Scheme Name:";
			this.laAuthor.AutoSize = true;
			this.laAuthor.Location = new Point(16, 8);
			this.laAuthor.Name = "laAuthor";
			this.laAuthor.Size = new Size(41, 13);
			this.laAuthor.TabIndex = 0;
			this.laAuthor.Text = "Author:";
			this.tbCopyright.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.tbCopyright.Location = new Point(16, 176);
			this.tbCopyright.Name = "tbCopyright";
			this.tbCopyright.Size = new Size(356, 20);
			this.tbCopyright.TabIndex = 7;
			this.tbCopyright.TextChanged += new EventHandler(this.tbCopyright_TextChanged);
			this.tbDescription.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.tbDescription.Location = new Point(16, 128);
			this.tbDescription.Name = "tbDescription";
			this.tbDescription.Size = new Size(356, 20);
			this.tbDescription.TabIndex = 5;
			this.tbDescription.TextChanged += new EventHandler(this.tbDescription_TextChanged);
			this.tbSchemeName.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.tbSchemeName.Location = new Point(16, 80);
			this.tbSchemeName.Name = "tbSchemeName";
			this.tbSchemeName.Size = new Size(356, 20);
			this.tbSchemeName.TabIndex = 3;
			this.tbSchemeName.TextChanged += new EventHandler(this.tbSchemeName_TextChanged);
			this.tbAuthor.Anchor = (AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right);
			this.tbAuthor.Location = new Point(16, 32);
			this.tbAuthor.Name = "tbAuthor";
			this.tbAuthor.Size = new Size(356, 20);
			this.tbAuthor.TabIndex = 1;
			this.tbAuthor.TextChanged += new EventHandler(this.tbAuthor_TextChanged);
			this.tpStyles.BackColor = Color.Transparent;
			this.tpStyles.Controls.Add(this.pnStyles);
			this.tpStyles.Location = new Point(4, 22);
			this.tpStyles.Name = "tpStyles";
			this.tpStyles.Size = new Size(392, 344);
			this.tpStyles.TabIndex = 1;
			this.tpStyles.Text = "Styles";
			this.pnStyles.BackColor = Color.Transparent;
			this.pnStyles.Controls.Add(this.gbStyles);
			this.pnStyles.Location = new Point(0, 0);
			this.pnStyles.Margin = new Padding(8);
			this.pnStyles.Name = "pnStyles";
			this.pnStyles.Size = new Size(386, 340);
			this.pnStyles.TabIndex = 4;
			this.pnStyles.Visible = false;
			this.gbStyles.BackColor = Color.Transparent;
			this.gbStyles.Controls.Add(this.lbStyles);
			this.gbStyles.Controls.Add(this.btRemoveStyle);
			this.gbStyles.Controls.Add(this.btMoveDownStyle);
			this.gbStyles.Controls.Add(this.btAddStyle);
			this.gbStyles.Controls.Add(this.btMoveUpStyle);
			this.gbStyles.Location = new Point(4, 4);
			this.gbStyles.Name = "gbStyles";
			this.gbStyles.Size = new Size(374, 156);
			this.gbStyles.TabIndex = 7;
			this.gbStyles.TabStop = false;
			this.gbStyles.Text = "Styles";
			this.lbStyles.FormattingEnabled = true;
			this.lbStyles.Location = new Point(6, 16);
			this.lbStyles.Name = "lbStyles";
			this.lbStyles.Size = new Size(326, 95);
			this.lbStyles.TabIndex = 0;
			this.lbStyles.SelectedIndexChanged += new EventHandler(this.lbStyles_SelectedIndexChanged);
			this.btRemoveStyle.Location = new Point(87, 117);
			this.btRemoveStyle.Name = "btRemoveStyle";
			this.btRemoveStyle.Size = new Size(75, 23);
			this.btRemoveStyle.TabIndex = 3;
			this.btRemoveStyle.Text = "Remove";
			this.btRemoveStyle.UseVisualStyleBackColor = true;
			this.btRemoveStyle.Click += new EventHandler(this.btRemoveStyle_Click);
			this.btMoveDownStyle.ImageIndex = 1;
			this.btMoveDownStyle.ImageList = this.imButtons;
			this.btMoveDownStyle.Location = new Point(338, 45);
			this.btMoveDownStyle.Name = "btMoveDownStyle";
			this.btMoveDownStyle.Size = new Size(30, 23);
			this.btMoveDownStyle.TabIndex = 6;
			this.btMoveDownStyle.UseVisualStyleBackColor = true;
			this.btMoveDownStyle.Click += new EventHandler(this.btMoveDownStyle_Click);
			this.imButtons.ImageStream = (ImageListStreamer)componentResourceManager.GetObject("imButtons.ImageStream");
			this.imButtons.TransparentColor = Color.Red;
			this.imButtons.Images.SetKeyName(0, "ButtonUp.bmp");
			this.imButtons.Images.SetKeyName(1, "ButtonDown.bmp");
			this.btAddStyle.Location = new Point(6, 117);
			this.btAddStyle.Name = "btAddStyle";
			this.btAddStyle.Size = new Size(75, 23);
			this.btAddStyle.TabIndex = 1;
			this.btAddStyle.Text = "Add";
			this.btAddStyle.UseVisualStyleBackColor = true;
			this.btAddStyle.Click += new EventHandler(this.btAddStyle_Click);
			this.btMoveUpStyle.ImageIndex = 0;
			this.btMoveUpStyle.ImageList = this.imButtons;
			this.btMoveUpStyle.Location = new Point(338, 16);
			this.btMoveUpStyle.Name = "btMoveUpStyle";
			this.btMoveUpStyle.Size = new Size(30, 23);
			this.btMoveUpStyle.TabIndex = 5;
			this.btMoveUpStyle.UseVisualStyleBackColor = true;
			this.btMoveUpStyle.Click += new EventHandler(this.btMoveUpStyle_Click);
			this.tpStates.BackColor = Color.Transparent;
			this.tpStates.Controls.Add(this.pnStates);
			this.tpStates.Location = new Point(4, 22);
			this.tpStates.Name = "tpStates";
			this.tpStates.Size = new Size(392, 344);
			this.tpStates.TabIndex = 2;
			this.tpStates.Text = "States";
			this.pnStates.BackColor = Color.Transparent;
			this.pnStates.Controls.Add(this.gbStates);
			this.pnStates.Location = new Point(0, 0);
			this.pnStates.Name = "pnStates";
			this.pnStates.Size = new Size(386, 340);
			this.pnStates.TabIndex = 3;
			this.gbStates.BackColor = Color.Transparent;
			this.gbStates.Controls.Add(this.lbStates);
			this.gbStates.Controls.Add(this.btAddState);
			this.gbStates.Controls.Add(this.btRemoveState);
			this.gbStates.Controls.Add(this.btMoveDownState);
			this.gbStates.Controls.Add(this.btMoveUpState);
			this.gbStates.Location = new Point(4, 4);
			this.gbStates.Name = "gbStates";
			this.gbStates.Size = new Size(374, 156);
			this.gbStates.TabIndex = 13;
			this.gbStates.TabStop = false;
			this.gbStates.Text = "States";
			this.lbStates.FormattingEnabled = true;
			this.lbStates.Location = new Point(6, 16);
			this.lbStates.Name = "lbStates";
			this.lbStates.Size = new Size(326, 95);
			this.lbStates.TabIndex = 7;
			this.lbStates.SelectedIndexChanged += new EventHandler(this.lbStates_SelectedIndexChanged);
			this.btAddState.Location = new Point(6, 117);
			this.btAddState.Name = "btAddState";
			this.btAddState.Size = new Size(75, 23);
			this.btAddState.TabIndex = 8;
			this.btAddState.Text = "Add";
			this.btAddState.UseVisualStyleBackColor = true;
			this.btAddState.Click += new EventHandler(this.btAddState_Click);
			this.btRemoveState.Location = new Point(87, 117);
			this.btRemoveState.Name = "btRemoveState";
			this.btRemoveState.Size = new Size(75, 23);
			this.btRemoveState.TabIndex = 10;
			this.btRemoveState.Text = "Remove";
			this.btRemoveState.UseVisualStyleBackColor = true;
			this.btRemoveState.Click += new EventHandler(this.btRemoveState_Click);
			this.btMoveDownState.ImageIndex = 1;
			this.btMoveDownState.ImageList = this.imButtons;
			this.btMoveDownState.Location = new Point(338, 45);
			this.btMoveDownState.Name = "btMoveDownState";
			this.btMoveDownState.Size = new Size(30, 23);
			this.btMoveDownState.TabIndex = 12;
			this.btMoveDownState.UseVisualStyleBackColor = true;
			this.btMoveDownState.Click += new EventHandler(this.btMoveDownState_Click);
			this.btMoveUpState.ImageIndex = 0;
			this.btMoveUpState.ImageList = this.imButtons;
			this.btMoveUpState.Location = new Point(338, 16);
			this.btMoveUpState.Name = "btMoveUpState";
			this.btMoveUpState.Size = new Size(30, 23);
			this.btMoveUpState.TabIndex = 11;
			this.btMoveUpState.UseVisualStyleBackColor = true;
			this.btMoveUpState.Click += new EventHandler(this.btMoveUpState_Click);
			this.tpStyle.Controls.Add(this.pnStyle);
			this.tpStyle.Location = new Point(4, 22);
			this.tpStyle.Name = "tpStyle";
			this.tpStyle.Padding = new Padding(3);
			this.tpStyle.Size = new Size(392, 344);
			this.tpStyle.TabIndex = 3;
			this.tpStyle.Text = "Style";
			this.tpStyle.UseVisualStyleBackColor = true;
			this.pnStyle.BackColor = Color.Transparent;
			this.pnStyle.Controls.Add(this.pnSample);
			this.pnStyle.Controls.Add(this.gbStyleProperties);
			this.pnStyle.Location = new Point(0, 0);
			this.pnStyle.Name = "pnStyle";
			this.pnStyle.Size = new Size(391, 340);
			this.pnStyle.TabIndex = 6;
			this.pnSample.BorderStyle = BorderStyle.Fixed3D;
			this.pnSample.Controls.Add(this.laSample);
			this.pnSample.Location = new Point(8, 208);
			this.pnSample.Name = "pnSample";
			this.pnSample.Size = new Size(364, 64);
			this.pnSample.TabIndex = 6;
			this.laSample.AutoSize = true;
			this.laSample.BorderStyle = BorderStyle.Fixed3D;
			this.laSample.Font = new Font("Microsoft Sans Serif", 18f, FontStyle.Regular, GraphicsUnit.Point, 204);
			this.laSample.Location = new Point(120, 16);
			this.laSample.Name = "laSample";
			this.laSample.Size = new Size(125, 31);
			this.laSample.TabIndex = 0;
			this.laSample.Text = "AaBbYyZz";
			this.gbStyleProperties.BackColor = Color.Transparent;
			this.gbStyleProperties.Controls.Add(this.chbPlainText);
			this.gbStyleProperties.Controls.Add(this.tbStyleName);
			this.gbStyleProperties.Controls.Add(this.laStyleName);
			this.gbStyleProperties.Controls.Add(this.laStyleBkColor);
			this.gbStyleProperties.Controls.Add(this.laStyleForeColor);
			this.gbStyleProperties.Controls.Add(this.tbStyleDesc);
			this.gbStyleProperties.Controls.Add(this.laStyleDesc);
			this.gbStyleProperties.Controls.Add(this.clbBkColor);
			this.gbStyleProperties.Controls.Add(this.clbForeColor);
			this.gbStyleProperties.Controls.Add(this.gbFontStyles);
			this.gbStyleProperties.Location = new Point(4, 4);
			this.gbStyleProperties.Name = "gbStyleProperties";
			this.gbStyleProperties.Size = new Size(374, 194);
			this.gbStyleProperties.TabIndex = 5;
			this.gbStyleProperties.TabStop = false;
			this.gbStyleProperties.Text = "Style Properties";
			this.chbPlainText.Location = new Point(247, 158);
			this.chbPlainText.Name = "chbPlainText";
			this.chbPlainText.Size = new Size(80, 24);
			this.chbPlainText.TabIndex = 8;
			this.chbPlainText.Text = "Plain Text";
			this.chbPlainText.CheckedChanged += new EventHandler(this.chbPlainText_CheckedChanged);
			this.tbStyleName.Location = new Point(16, 32);
			this.tbStyleName.Name = "tbStyleName";
			this.tbStyleName.Size = new Size(208, 20);
			this.tbStyleName.TabIndex = 1;
			this.tbStyleName.TextChanged += new EventHandler(this.tbStyleName_TextChanged);
			this.laStyleName.AutoSize = true;
			this.laStyleName.Location = new Point(16, 16);
			this.laStyleName.Name = "laStyleName";
			this.laStyleName.Size = new Size(38, 13);
			this.laStyleName.TabIndex = 0;
			this.laStyleName.Text = "Name:";
			this.laStyleBkColor.AutoSize = true;
			this.laStyleBkColor.Location = new Point(16, 144);
			this.laStyleBkColor.Name = "laStyleBkColor";
			this.laStyleBkColor.Size = new Size(62, 13);
			this.laStyleBkColor.TabIndex = 6;
			this.laStyleBkColor.Text = "Back Color:";
			this.laStyleForeColor.AutoSize = true;
			this.laStyleForeColor.Location = new Point(16, 98);
			this.laStyleForeColor.Name = "laStyleForeColor";
			this.laStyleForeColor.Size = new Size(58, 13);
			this.laStyleForeColor.TabIndex = 4;
			this.laStyleForeColor.Text = "Fore Color:";
			this.tbStyleDesc.Location = new Point(16, 72);
			this.tbStyleDesc.Name = "tbStyleDesc";
			this.tbStyleDesc.Size = new Size(208, 20);
			this.tbStyleDesc.TabIndex = 3;
			this.tbStyleDesc.TextChanged += new EventHandler(this.tbStyleDesc_TextChanged);
			this.laStyleDesc.AutoSize = true;
			this.laStyleDesc.Location = new Point(16, 56);
			this.laStyleDesc.Name = "laStyleDesc";
			this.laStyleDesc.Size = new Size(63, 13);
			this.laStyleDesc.TabIndex = 2;
			this.laStyleDesc.Text = "Description:";
			this.clbBkColor.DrawMode = DrawMode.OwnerDrawFixed;
			this.clbBkColor.DropDownStyle = ComboBoxStyle.DropDownList;
			this.clbBkColor.Location = new Point(16, 160);
			this.clbBkColor.Name = "clbBkColor";
			this.clbBkColor.SelectedColor = Color.Empty;
			this.clbBkColor.Size = new Size(208, 21);
			this.clbBkColor.TabIndex = 7;
			this.clbBkColor.SelectedIndexChanged += new EventHandler(this.clbBkColor_SelectedIndexChanged);
			this.clbForeColor.DrawMode = DrawMode.OwnerDrawFixed;
			this.clbForeColor.DropDownStyle = ComboBoxStyle.DropDownList;
			this.clbForeColor.Location = new Point(16, 114);
			this.clbForeColor.Name = "clbForeColor";
			this.clbForeColor.SelectedColor = Color.Empty;
			this.clbForeColor.Size = new Size(208, 21);
			this.clbForeColor.TabIndex = 5;
			this.clbForeColor.SelectedIndexChanged += new EventHandler(this.clbForeColor_SelectedIndexChanged);
			this.gbFontStyles.Controls.Add(this.chbStrikeout);
			this.gbFontStyles.Controls.Add(this.chbItalic);
			this.gbFontStyles.Controls.Add(this.chbUnderline);
			this.gbFontStyles.Controls.Add(this.chbBold);
			this.gbFontStyles.Location = new Point(247, 32);
			this.gbFontStyles.Name = "gbFontStyles";
			this.gbFontStyles.Size = new Size(112, 120);
			this.gbFontStyles.TabIndex = 9;
			this.gbFontStyles.TabStop = false;
			this.gbFontStyles.Text = "Font Styles";
			this.chbStrikeout.Location = new Point(16, 88);
			this.chbStrikeout.Name = "chbStrikeout";
			this.chbStrikeout.Size = new Size(80, 24);
			this.chbStrikeout.TabIndex = 3;
			this.chbStrikeout.Text = "StrikeOut";
			this.chbStrikeout.CheckedChanged += new EventHandler(this.chbStrikeout_CheckedChanged);
			this.chbItalic.Location = new Point(16, 40);
			this.chbItalic.Name = "chbItalic";
			this.chbItalic.Size = new Size(80, 24);
			this.chbItalic.TabIndex = 1;
			this.chbItalic.Text = "Italic";
			this.chbItalic.CheckedChanged += new EventHandler(this.chbItalic_CheckedChanged);
			this.chbUnderline.Location = new Point(16, 64);
			this.chbUnderline.Name = "chbUnderline";
			this.chbUnderline.Size = new Size(80, 24);
			this.chbUnderline.TabIndex = 2;
			this.chbUnderline.Text = "Underline";
			this.chbUnderline.CheckedChanged += new EventHandler(this.chbUnderline_CheckedChanged);
			this.chbBold.Location = new Point(16, 16);
			this.chbBold.Name = "chbBold";
			this.chbBold.Size = new Size(80, 24);
			this.chbBold.TabIndex = 0;
			this.chbBold.Text = "Bold";
			this.chbBold.CheckedChanged += new EventHandler(this.chbBold_CheckedChanged);
			this.tpState.Controls.Add(this.pnState);
			this.tpState.Location = new Point(4, 22);
			this.tpState.Name = "tpState";
			this.tpState.Padding = new Padding(3);
			this.tpState.Size = new Size(392, 344);
			this.tpState.TabIndex = 4;
			this.tpState.Text = "State";
			this.tpState.UseVisualStyleBackColor = true;
			this.pnState.Controls.Add(this.gbSyntaxBlocks);
			this.pnState.Controls.Add(this.gbStateProperties);
			this.pnState.Location = new Point(0, 0);
			this.pnState.Name = "pnState";
			this.pnState.Size = new Size(388, 340);
			this.pnState.TabIndex = 0;
			this.gbSyntaxBlocks.Controls.Add(this.lbSyntaxBlocks);
			this.gbSyntaxBlocks.Controls.Add(this.btAddBlock);
			this.gbSyntaxBlocks.Controls.Add(this.btRemoveBlock);
			this.gbSyntaxBlocks.Controls.Add(this.btMoveDownBlock);
			this.gbSyntaxBlocks.Controls.Add(this.btMoveUpBlock);
			this.gbSyntaxBlocks.Location = new Point(4, 100);
			this.gbSyntaxBlocks.Name = "gbSyntaxBlocks";
			this.gbSyntaxBlocks.Size = new Size(374, 156);
			this.gbSyntaxBlocks.TabIndex = 16;
			this.gbSyntaxBlocks.TabStop = false;
			this.gbSyntaxBlocks.Text = "Syntax Blocks";
			this.lbSyntaxBlocks.FormattingEnabled = true;
			this.lbSyntaxBlocks.Location = new Point(6, 16);
			this.lbSyntaxBlocks.Name = "lbSyntaxBlocks";
			this.lbSyntaxBlocks.Size = new Size(326, 95);
			this.lbSyntaxBlocks.TabIndex = 7;
			this.lbSyntaxBlocks.SelectedIndexChanged += new EventHandler(this.lbSyntaxBlocks_SelectedIndexChanged);
			this.btAddBlock.Location = new Point(6, 117);
			this.btAddBlock.Name = "btAddBlock";
			this.btAddBlock.Size = new Size(75, 23);
			this.btAddBlock.TabIndex = 8;
			this.btAddBlock.Text = "Add";
			this.btAddBlock.UseVisualStyleBackColor = true;
			this.btAddBlock.Click += new EventHandler(this.btAddBlock_Click);
			this.btRemoveBlock.Location = new Point(87, 117);
			this.btRemoveBlock.Name = "btRemoveBlock";
			this.btRemoveBlock.Size = new Size(75, 23);
			this.btRemoveBlock.TabIndex = 10;
			this.btRemoveBlock.Text = "Remove";
			this.btRemoveBlock.UseVisualStyleBackColor = true;
			this.btRemoveBlock.Click += new EventHandler(this.btRemoveBlock_Click);
			this.btMoveDownBlock.ImageIndex = 1;
			this.btMoveDownBlock.ImageList = this.imButtons;
			this.btMoveDownBlock.Location = new Point(338, 45);
			this.btMoveDownBlock.Name = "btMoveDownBlock";
			this.btMoveDownBlock.Size = new Size(30, 23);
			this.btMoveDownBlock.TabIndex = 12;
			this.btMoveDownBlock.UseVisualStyleBackColor = true;
			this.btMoveDownBlock.Click += new EventHandler(this.btMoveDownBlock_Click);
			this.btMoveUpBlock.ImageIndex = 0;
			this.btMoveUpBlock.ImageList = this.imButtons;
			this.btMoveUpBlock.Location = new Point(338, 16);
			this.btMoveUpBlock.Name = "btMoveUpBlock";
			this.btMoveUpBlock.Size = new Size(30, 23);
			this.btMoveUpBlock.TabIndex = 11;
			this.btMoveUpBlock.UseVisualStyleBackColor = true;
			this.btMoveUpBlock.Click += new EventHandler(this.btMoveUpBlock_Click);
			this.gbStateProperties.Controls.Add(this.tbStateName);
			this.gbStateProperties.Controls.Add(this.laStateName);
			this.gbStateProperties.Controls.Add(this.laStateDesc);
			this.gbStateProperties.Controls.Add(this.tbStateDesc);
			this.gbStateProperties.Controls.Add(this.chbCaseSensitive);
			this.gbStateProperties.Location = new Point(4, 4);
			this.gbStateProperties.Name = "gbStateProperties";
			this.gbStateProperties.Size = new Size(374, 92);
			this.gbStateProperties.TabIndex = 1;
			this.gbStateProperties.TabStop = false;
			this.gbStateProperties.Text = "State Properties";
			this.tbStateName.Location = new Point(112, 16);
			this.tbStateName.Name = "tbStateName";
			this.tbStateName.Size = new Size(248, 20);
			this.tbStateName.TabIndex = 1;
			this.tbStateName.TextChanged += new EventHandler(this.tbStateName_TextChanged);
			this.laStateName.AutoSize = true;
			this.laStateName.Location = new Point(8, 19);
			this.laStateName.Name = "laStateName";
			this.laStateName.Size = new Size(38, 13);
			this.laStateName.TabIndex = 0;
			this.laStateName.Text = "Name:";
			this.laStateDesc.AutoSize = true;
			this.laStateDesc.Location = new Point(8, 43);
			this.laStateDesc.Name = "laStateDesc";
			this.laStateDesc.Size = new Size(63, 13);
			this.laStateDesc.TabIndex = 2;
			this.laStateDesc.Text = "Description:";
			this.tbStateDesc.Location = new Point(112, 40);
			this.tbStateDesc.Name = "tbStateDesc";
			this.tbStateDesc.Size = new Size(248, 20);
			this.tbStateDesc.TabIndex = 3;
			this.tbStateDesc.TextChanged += new EventHandler(this.tbStateDesc_TextChanged);
			this.chbCaseSensitive.Location = new Point(112, 62);
			this.chbCaseSensitive.Name = "chbCaseSensitive";
			this.chbCaseSensitive.Size = new Size(104, 24);
			this.chbCaseSensitive.TabIndex = 4;
			this.chbCaseSensitive.Text = "CaseSensitive";
			this.chbCaseSensitive.CheckedChanged += new EventHandler(this.chbCaseSensitive_CheckedChanged);
			this.tpSyntaxBlock.Controls.Add(this.pnSyntaxBlock);
			this.tpSyntaxBlock.Location = new Point(4, 22);
			this.tpSyntaxBlock.Name = "tpSyntaxBlock";
			this.tpSyntaxBlock.Padding = new Padding(3);
			this.tpSyntaxBlock.Size = new Size(392, 344);
			this.tpSyntaxBlock.TabIndex = 5;
			this.tpSyntaxBlock.Text = "Syntax Block";
			this.tpSyntaxBlock.UseVisualStyleBackColor = true;
			this.pnSyntaxBlock.Controls.Add(this.gbReswordSets);
			this.pnSyntaxBlock.Controls.Add(this.gbSyntaxBlockProperties);
			this.pnSyntaxBlock.Location = new Point(0, 0);
			this.pnSyntaxBlock.Name = "pnSyntaxBlock";
			this.pnSyntaxBlock.Size = new Size(388, 340);
			this.pnSyntaxBlock.TabIndex = 0;
			this.gbReswordSets.Controls.Add(this.lbReswordSets);
			this.gbReswordSets.Controls.Add(this.btAddReswordSet);
			this.gbReswordSets.Controls.Add(this.btRemoveReswordSet);
			this.gbReswordSets.Controls.Add(this.btMoveDownReswordSet);
			this.gbReswordSets.Controls.Add(this.btMoveUpReswordSet);
			this.gbReswordSets.Location = new Point(4, 192);
			this.gbReswordSets.Name = "gbReswordSets";
			this.gbReswordSets.Size = new Size(374, 156);
			this.gbReswordSets.TabIndex = 17;
			this.gbReswordSets.TabStop = false;
			this.gbReswordSets.Text = "Resword Sets";
			this.lbReswordSets.FormattingEnabled = true;
			this.lbReswordSets.Location = new Point(6, 16);
			this.lbReswordSets.Name = "lbReswordSets";
			this.lbReswordSets.Size = new Size(326, 95);
			this.lbReswordSets.TabIndex = 7;
			this.lbReswordSets.SelectedIndexChanged += new EventHandler(this.lbReswordSets_SelectedIndexChanged);
			this.btAddReswordSet.Location = new Point(6, 117);
			this.btAddReswordSet.Name = "btAddReswordSet";
			this.btAddReswordSet.Size = new Size(75, 23);
			this.btAddReswordSet.TabIndex = 8;
			this.btAddReswordSet.Text = "Add";
			this.btAddReswordSet.UseVisualStyleBackColor = true;
			this.btAddReswordSet.Click += new EventHandler(this.btAddReswordSet_Click);
			this.btRemoveReswordSet.Location = new Point(87, 117);
			this.btRemoveReswordSet.Name = "btRemoveReswordSet";
			this.btRemoveReswordSet.Size = new Size(75, 23);
			this.btRemoveReswordSet.TabIndex = 10;
			this.btRemoveReswordSet.Text = "Remove";
			this.btRemoveReswordSet.UseVisualStyleBackColor = true;
			this.btRemoveReswordSet.Click += new EventHandler(this.btRemoveReswordSet_Click);
			this.btMoveDownReswordSet.ImageIndex = 1;
			this.btMoveDownReswordSet.ImageList = this.imButtons;
			this.btMoveDownReswordSet.Location = new Point(338, 45);
			this.btMoveDownReswordSet.Name = "btMoveDownReswordSet";
			this.btMoveDownReswordSet.Size = new Size(30, 23);
			this.btMoveDownReswordSet.TabIndex = 12;
			this.btMoveDownReswordSet.UseVisualStyleBackColor = true;
			this.btMoveDownReswordSet.Click += new EventHandler(this.btMoveDownReswordSet_Click);
			this.btMoveUpReswordSet.ImageIndex = 0;
			this.btMoveUpReswordSet.ImageList = this.imButtons;
			this.btMoveUpReswordSet.Location = new Point(338, 16);
			this.btMoveUpReswordSet.Name = "btMoveUpReswordSet";
			this.btMoveUpReswordSet.Size = new Size(30, 23);
			this.btMoveUpReswordSet.TabIndex = 11;
			this.btMoveUpReswordSet.UseVisualStyleBackColor = true;
			this.btMoveUpReswordSet.Click += new EventHandler(this.btMoveUpReswordSet_Click);
			this.gbSyntaxBlockProperties.Controls.Add(this.tbExpressions);
			this.gbSyntaxBlockProperties.Controls.Add(this.tbBlockName);
			this.gbSyntaxBlockProperties.Controls.Add(this.laBlockName);
			this.gbSyntaxBlockProperties.Controls.Add(this.laBlockExpr);
			this.gbSyntaxBlockProperties.Controls.Add(this.tbBlockDesc);
			this.gbSyntaxBlockProperties.Controls.Add(this.laBlockDesc);
			this.gbSyntaxBlockProperties.Controls.Add(this.laLeaveState);
			this.gbSyntaxBlockProperties.Controls.Add(this.laStyle);
			this.gbSyntaxBlockProperties.Controls.Add(this.cbLeaveState);
			this.gbSyntaxBlockProperties.Controls.Add(this.cbStyle);
			this.gbSyntaxBlockProperties.Location = new Point(4, 4);
			this.gbSyntaxBlockProperties.Name = "gbSyntaxBlockProperties";
			this.gbSyntaxBlockProperties.Size = new Size(374, 184);
			this.gbSyntaxBlockProperties.TabIndex = 3;
			this.gbSyntaxBlockProperties.TabStop = false;
			this.gbSyntaxBlockProperties.Text = "Block Properties";
			this.tbExpressions.Location = new Point(112, 112);
			this.tbExpressions.Multiline = true;
			this.tbExpressions.Name = "tbExpressions";
			this.tbExpressions.ScrollBars = ScrollBars.Vertical;
			this.tbExpressions.Size = new Size(248, 64);
			this.tbExpressions.TabIndex = 12;
			this.tbExpressions.TextChanged += new EventHandler(this.tbExpressions_TextChanged);
			this.tbBlockName.Location = new Point(112, 16);
			this.tbBlockName.Name = "tbBlockName";
			this.tbBlockName.Size = new Size(248, 20);
			this.tbBlockName.TabIndex = 1;
			this.tbBlockName.TextChanged += new EventHandler(this.tbBlockName_TextChanged);
			this.laBlockName.AutoSize = true;
			this.laBlockName.Location = new Point(8, 19);
			this.laBlockName.Name = "laBlockName";
			this.laBlockName.Size = new Size(38, 13);
			this.laBlockName.TabIndex = 0;
			this.laBlockName.Text = "Name:";
			this.laBlockExpr.AutoSize = true;
			this.laBlockExpr.Location = new Point(8, 115);
			this.laBlockExpr.Name = "laBlockExpr";
			this.laBlockExpr.Size = new Size(66, 13);
			this.laBlockExpr.TabIndex = 8;
			this.laBlockExpr.Text = "Expressions:";
			this.tbBlockDesc.Location = new Point(112, 40);
			this.tbBlockDesc.Name = "tbBlockDesc";
			this.tbBlockDesc.Size = new Size(248, 20);
			this.tbBlockDesc.TabIndex = 3;
			this.tbBlockDesc.TextChanged += new EventHandler(this.tbBlockDesc_TextChanged);
			this.laBlockDesc.AutoSize = true;
			this.laBlockDesc.Location = new Point(8, 43);
			this.laBlockDesc.Name = "laBlockDesc";
			this.laBlockDesc.Size = new Size(63, 13);
			this.laBlockDesc.TabIndex = 2;
			this.laBlockDesc.Text = "Description:";
			this.laLeaveState.AutoSize = true;
			this.laLeaveState.Location = new Point(8, 67);
			this.laLeaveState.Name = "laLeaveState";
			this.laLeaveState.Size = new Size(68, 13);
			this.laLeaveState.TabIndex = 4;
			this.laLeaveState.Text = "Leave State:";
			this.laStyle.AutoSize = true;
			this.laStyle.Location = new Point(8, 91);
			this.laStyle.Name = "laStyle";
			this.laStyle.Size = new Size(33, 13);
			this.laStyle.TabIndex = 6;
			this.laStyle.Text = "Style:";
			this.cbLeaveState.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbLeaveState.Location = new Point(112, 64);
			this.cbLeaveState.Name = "cbLeaveState";
			this.cbLeaveState.Size = new Size(248, 21);
			this.cbLeaveState.TabIndex = 5;
			this.cbLeaveState.SelectedIndexChanged += new EventHandler(this.cbLeaveState_SelectedIndexChanged);
			this.cbStyle.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbStyle.Location = new Point(112, 88);
			this.cbStyle.Name = "cbStyle";
			this.cbStyle.Size = new Size(248, 21);
			this.cbStyle.TabIndex = 7;
			this.cbStyle.SelectedIndexChanged += new EventHandler(this.cbStyle_SelectedIndexChanged);
			this.tpReswordSet.Controls.Add(this.pnReswordSet);
			this.tpReswordSet.Location = new Point(4, 22);
			this.tpReswordSet.Name = "tpReswordSet";
			this.tpReswordSet.Padding = new Padding(3);
			this.tpReswordSet.Size = new Size(392, 344);
			this.tpReswordSet.TabIndex = 6;
			this.tpReswordSet.Text = "Resword Set";
			this.tpReswordSet.UseVisualStyleBackColor = true;
			this.pnReswordSet.Controls.Add(this.gbreswordsProperties);
			this.pnReswordSet.Location = new Point(0, 0);
			this.pnReswordSet.Name = "pnReswordSet";
			this.pnReswordSet.Size = new Size(388, 340);
			this.pnReswordSet.TabIndex = 0;
			this.gbreswordsProperties.Controls.Add(this.tbreswordSetName);
			this.gbreswordsProperties.Controls.Add(this.lareswordSetName);
			this.gbreswordsProperties.Controls.Add(this.cbreswordStyle);
			this.gbreswordsProperties.Controls.Add(this.tbreswords);
			this.gbreswordsProperties.Controls.Add(this.laBlockreswords);
			this.gbreswordsProperties.Controls.Add(this.lareswordStyle);
			this.gbreswordsProperties.Location = new Point(4, 4);
			this.gbreswordsProperties.Name = "gbreswordsProperties";
			this.gbreswordsProperties.Size = new Size(374, 140);
			this.gbreswordsProperties.TabIndex = 4;
			this.gbreswordsProperties.TabStop = false;
			this.gbreswordsProperties.Text = "Resword Set Properties";
			this.tbreswordSetName.Location = new Point(112, 16);
			this.tbreswordSetName.Name = "tbreswordSetName";
			this.tbreswordSetName.Size = new Size(248, 20);
			this.tbreswordSetName.TabIndex = 1;
			this.tbreswordSetName.TextChanged += new EventHandler(this.tbreswordSetName_TextChanged);
			this.lareswordSetName.AutoSize = true;
			this.lareswordSetName.Location = new Point(8, 19);
			this.lareswordSetName.Name = "lareswordSetName";
			this.lareswordSetName.Size = new Size(38, 13);
			this.lareswordSetName.TabIndex = 0;
			this.lareswordSetName.Text = "Name:";
			this.cbreswordStyle.DropDownStyle = ComboBoxStyle.DropDownList;
			this.cbreswordStyle.Location = new Point(112, 40);
			this.cbreswordStyle.Name = "cbreswordStyle";
			this.cbreswordStyle.Size = new Size(248, 21);
			this.cbreswordStyle.TabIndex = 3;
			this.cbreswordStyle.SelectedIndexChanged += new EventHandler(this.cbreswordStyle_SelectedIndexChanged);
			this.tbreswords.Location = new Point(112, 70);
			this.tbreswords.Multiline = true;
			this.tbreswords.Name = "tbreswords";
			this.tbreswords.ScrollBars = ScrollBars.Vertical;
			this.tbreswords.Size = new Size(248, 64);
			this.tbreswords.TabIndex = 5;
			this.tbreswords.TextChanged += new EventHandler(this.tbreswords_TextChanged);
			this.laBlockreswords.AutoSize = true;
			this.laBlockreswords.Location = new Point(8, 67);
			this.laBlockreswords.Name = "laBlockreswords";
			this.laBlockreswords.Size = new Size(52, 13);
			this.laBlockreswords.TabIndex = 4;
			this.laBlockreswords.Text = "reswords:";
			this.lareswordStyle.AutoSize = true;
			this.lareswordStyle.Location = new Point(8, 43);
			this.lareswordStyle.Name = "lareswordStyle";
			this.lareswordStyle.Size = new Size(73, 13);
			this.lareswordStyle.TabIndex = 2;
			this.lareswordStyle.Text = "resword Style:";
			this.ilButtons.ImageStream = (ImageListStreamer)componentResourceManager.GetObject("ilButtons.ImageStream");
			this.ilButtons.TransparentColor = SystemColors.Control;
			this.ilButtons.Images.SetKeyName(0, "");
			this.ilButtons.Images.SetKeyName(1, "");
			this.ilButtons.Images.SetKeyName(2, "");
			base.AutoScaleMode = AutoScaleMode.None;
			base.ClientSize = new Size(590, 420);
			base.Controls.Add(this.pnMain);
			base.Controls.Add(this.tvLexer);
			base.Controls.Add(this.pnButtons);
			base.FormBorderStyle = FormBorderStyle.FixedSingle;
			base.Name = "DlgSyntaxBuilder";
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "Syntax Scheme Builder";
			base.Load += new EventHandler(this.MainForm_Load);
			base.Closing += new CancelEventHandler(this.DlgSyntaxBuilder_Closing);
			this.pnButtons.ResumeLayout(false);
			this.pnMain.ResumeLayout(false);
			this.tcPanels.ResumeLayout(false);
			this.tpGeneral.ResumeLayout(false);
			this.pnGeneral.ResumeLayout(false);
			this.pnGeneral.PerformLayout();
			this.tpStyles.ResumeLayout(false);
			this.pnStyles.ResumeLayout(false);
			this.gbStyles.ResumeLayout(false);
			this.tpStates.ResumeLayout(false);
			this.pnStates.ResumeLayout(false);
			this.gbStates.ResumeLayout(false);
			this.tpStyle.ResumeLayout(false);
			this.pnStyle.ResumeLayout(false);
			this.pnSample.ResumeLayout(false);
			this.pnSample.PerformLayout();
			this.gbStyleProperties.ResumeLayout(false);
			this.gbStyleProperties.PerformLayout();
			this.gbFontStyles.ResumeLayout(false);
			this.tpState.ResumeLayout(false);
			this.pnState.ResumeLayout(false);
			this.gbSyntaxBlocks.ResumeLayout(false);
			this.gbStateProperties.ResumeLayout(false);
			this.gbStateProperties.PerformLayout();
			this.tpSyntaxBlock.ResumeLayout(false);
			this.pnSyntaxBlock.ResumeLayout(false);
			this.gbReswordSets.ResumeLayout(false);
			this.gbSyntaxBlockProperties.ResumeLayout(false);
			this.gbSyntaxBlockProperties.PerformLayout();
			this.tpReswordSet.ResumeLayout(false);
			this.pnReswordSet.ResumeLayout(false);
			this.gbreswordsProperties.ResumeLayout(false);
			this.gbreswordsProperties.PerformLayout();
			base.ResumeLayout(false);
		}
		private bool IsSyntaxBlockComplete(LexScheme scheme, LexState state, LexSyntaxBlock block, out string errorMsg)
		{
			errorMsg = string.Empty;
			bool flag = true;
			bool result;
			if (block.LeaveState == null)
			{
				errorMsg = string.Format(SyntaxBuilderConsts.IncompleteLeaveState, state.Name, block.Name);
				result = false;
			}
			else
			{
				if (block.Style == null)
				{
					errorMsg = string.Format(SyntaxBuilderConsts.IncompleteLeaveStyle, state.Name, block.Name);
					result = false;
				}
				else
				{
					using (IEnumerator<LexReswordSet> enumerator = block.ReswordSets.GetEnumerator())
					{
						while (enumerator.MoveNext())
						{
							LexReswordSet lexReswordSet = (LexReswordSet)enumerator.Current;
							if (lexReswordSet.Reswords.Count > 0 && lexReswordSet.ReswordStyle == null)
							{
								errorMsg = string.Format(SyntaxBuilderConsts.IncompleteReswordStyle, state.Name, block.Name, lexReswordSet.Name);
								result = false;
								return result;
							}
						}
					}
					result = flag;
				}
			}
			return result;
		}
		private bool IsStateComplete(LexScheme scheme, LexState state, out string errorMsg)
		{
			errorMsg = string.Empty;
			bool result = true;
			foreach (LexSyntaxBlock current in state.SyntaxBlocks)
			{
				if (!this.IsSyntaxBlockComplete(scheme, state, current, out errorMsg))
				{
					result = false;
					break;
				}
			}
			return result;
		}
		private bool IsSchemeComplete(LexScheme scheme, out string errorMsg)
		{
			errorMsg = string.Empty;
			bool result = true;
			for (int i = 0; i < scheme.States.Count; i++)
			{
				if (!this.IsStateComplete(scheme, scheme.States[i], out errorMsg))
				{
					result = false;
					break;
				}
			}
			return result;
		}
		private int GetNodeLevel(TreeNode node)
		{
			int result;
			if (node == null)
			{
				result = -1;
			}
			else
			{
				TreeNode treeNode = node;
				int num = -1;
				while (treeNode != null)
				{
					treeNode = treeNode.Parent;
					num++;
				}
				result = num;
			}
			return result;
		}
		private DlgSyntaxBuilder.NodeKind GetNodeKind(TreeNode node)
		{
			DlgSyntaxBuilder.NodeKind result;
			if (node != null)
			{
				int nodeLevel = this.GetNodeLevel(node);
				TreeNode parent = node.Parent;
				switch (nodeLevel)
				{
				case 0:
					result = DlgSyntaxBuilder.NodeKind.nkGeneral;
					break;
				case 1:
					switch (node.Index)
					{
					case 0:
						result = DlgSyntaxBuilder.NodeKind.nkStyles;
						break;
					case 1:
						result = DlgSyntaxBuilder.NodeKind.nkStates;
						break;
					default:
						result = DlgSyntaxBuilder.NodeKind.nkNone;
						break;
					}
					break;
				case 2:
					if (parent == this.stylesNode)
					{
						result = DlgSyntaxBuilder.NodeKind.nkStyle;
					}
					else
					{
						if (parent == this.statesNode)
						{
							result = DlgSyntaxBuilder.NodeKind.nkState;
						}
						else
						{
							result = DlgSyntaxBuilder.NodeKind.nkNone;
						}
					}
					break;
				case 3:
					result = DlgSyntaxBuilder.NodeKind.nkSyntaxBlock;
					break;
				case 4:
					result = DlgSyntaxBuilder.NodeKind.nkreswordSet;
					break;
				default:
					result = DlgSyntaxBuilder.NodeKind.nkNone;
					break;
				}
			}
			else
			{
				result = DlgSyntaxBuilder.NodeKind.nkNone;
			}
			return result;
		}
		private TreeNode GetStyleNode(TreeNode node)
		{
			TreeNode result;
			switch (this.GetNodeKind(node))
			{
			case DlgSyntaxBuilder.NodeKind.nkStyles:
				if (node.Nodes.Count > 0)
				{
					result = node.Nodes[0];
				}
				else
				{
					result = null;
				}
				break;
			case DlgSyntaxBuilder.NodeKind.nkStyle:
				result = node;
				break;
			default:
				result = null;
				break;
			}
			return result;
		}
		private TreeNode GetStateNode(TreeNode node)
		{
			TreeNode result;
			switch (this.GetNodeKind(node))
			{
			case DlgSyntaxBuilder.NodeKind.nkStates:
				if (this.statesNode.Nodes.Count > 0)
				{
					result = node.Nodes[0];
					return result;
				}
				result = null;
				return result;
			case DlgSyntaxBuilder.NodeKind.nkState:
				result = node;
				return result;
			case DlgSyntaxBuilder.NodeKind.nkSyntaxBlock:
				result = node.Parent;
				return result;
			case DlgSyntaxBuilder.NodeKind.nkreswordSet:
				result = node.Parent.Parent;
				return result;
			}
			result = null;
			return result;
		}
		private TreeNode GetSyntaxBlockNode(TreeNode node)
		{
			DlgSyntaxBuilder.NodeKind nodeKind = this.GetNodeKind(node);
			TreeNode result;
			if (nodeKind == DlgSyntaxBuilder.NodeKind.nkSyntaxBlock)
			{
				result = node;
			}
			else
			{
				if (nodeKind == DlgSyntaxBuilder.NodeKind.nkreswordSet)
				{
					result = node.Parent;
				}
				else
				{
					result = null;
				}
			}
			return result;
		}
		private LexSyntaxBlock GetLexSyntaxBlock(TreeNode node, LexScheme scheme)
		{
			DlgSyntaxBuilder.NodeKind nodeKind = this.GetNodeKind(node);
			LexSyntaxBlock result;
			if (nodeKind != DlgSyntaxBuilder.NodeKind.nkSyntaxBlock && nodeKind != DlgSyntaxBuilder.NodeKind.nkreswordSet)
			{
				result = null;
			}
			else
			{
				LexState lexState = this.GetLexState(node.Parent, scheme);
				if (nodeKind == DlgSyntaxBuilder.NodeKind.nkreswordSet)
				{
					node = node.Parent;
				}
				result = ((lexState != null) ? lexState.SyntaxBlocks[node.Index] : null);
			}
			return result;
		}
		private LexReswordSet GetLexReswordSet(TreeNode node, LexScheme scheme)
		{
			DlgSyntaxBuilder.NodeKind nodeKind = this.GetNodeKind(node);
			LexReswordSet result;
			if (nodeKind != DlgSyntaxBuilder.NodeKind.nkreswordSet)
			{
				result = null;
			}
			else
			{
				LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(node.Parent, scheme);
				result = ((lexSyntaxBlock != null) ? lexSyntaxBlock.ReswordSets[node.Index] : null);
			}
			return result;
		}
		private void UpdateGeneralPanel()
		{
			this.pnGeneral.Visible = true;
			this.updating = true;
			try
			{
				this.tbAuthor.Text = this.Scheme.Author;
				this.tbDescription.Text = this.Scheme.Desc;
				this.tbCopyright.Text = this.Scheme.Copyright;
				this.tbSchemeName.Text = this.Scheme.Name;
				this.tbFileType.Text = this.Scheme.FileType;
				this.tbFileExt.Text = this.Scheme.FileExtension;
			}
			finally
			{
				this.updating = false;
			}
		}
		private void UpdateStylePanel()
		{
			this.pnStyle.Visible = true;
			this.UpdateStyleControls();
		}
		private void UpdateStylesPanel()
		{
			this.pnStyles.Visible = true;
			this.UpdateStylesControls();
		}
		private void UpdateStatePanel()
		{
			this.pnState.Visible = true;
			this.UpdateStateControls();
		}
		private void UpdateStatesPanel()
		{
			this.pnStates.Visible = true;
			this.UpdateStatesControls();
		}
		private void UpdateSyntaxBlockPanel()
		{
			this.pnSyntaxBlock.Visible = true;
			this.UpdateSyntaxBlockControls();
		}
		private void UpdateReswordSetPanel()
		{
			this.pnReswordSet.Visible = true;
			this.UpdateReswordSetControls();
		}
		private void UpdatePanelControls(DlgSyntaxBuilder.NodeKind kind)
		{
			switch (kind)
			{
			case DlgSyntaxBuilder.NodeKind.nkStyles:
				this.UpdateStylesPanel();
				break;
			case DlgSyntaxBuilder.NodeKind.nkStyle:
				this.UpdateStylePanel();
				break;
			case DlgSyntaxBuilder.NodeKind.nkStates:
				this.UpdateStatesPanel();
				break;
			case DlgSyntaxBuilder.NodeKind.nkState:
				this.UpdateStatePanel();
				break;
			case DlgSyntaxBuilder.NodeKind.nkSyntaxBlock:
				this.UpdateSyntaxBlockPanel();
				break;
			case DlgSyntaxBuilder.NodeKind.nkGeneral:
				this.UpdateGeneralPanel();
				break;
			case DlgSyntaxBuilder.NodeKind.nkreswordSet:
				this.UpdateReswordSetPanel();
				break;
			}
		}
		private void UpdateVisible(DlgSyntaxBuilder.NodeKind kind)
		{
			Panel currentPanel = this.GetCurrentPanel(kind);
			if (currentPanel != null)
			{
				this.pnMain.Controls.Add(currentPanel);
			}
			for (int i = 0; i < this.pnMain.Controls.Count; i++)
			{
				if (!this.pnMain.Controls[i].Equals(currentPanel) && this.pnMain.Controls[i] is Panel)
				{
					this.pnMain.Controls[i].Visible = false;
				}
			}
			currentPanel.Dock = DockStyle.Fill;
			currentPanel.BringToFront();
			this.UpdatePanelControls(kind);
		}
		private void UpdateImages()
		{
			TreeNode folderNode = this.GetFolderNode();
			if (this.rootNode == this.stylesNode)
			{
				this.rootNode.ImageIndex = 0;
			}
			else
			{
				this.rootNode.ImageIndex = 1;
			}
			if (folderNode == this.stylesNode)
			{
				this.stylesNode.ImageIndex = 0;
			}
			else
			{
				this.stylesNode.ImageIndex = 1;
			}
			if (folderNode == this.statesNode)
			{
				this.statesNode.ImageIndex = 0;
			}
			else
			{
				this.statesNode.ImageIndex = 1;
			}
		}
		private void UpdateTree(TreeNode node)
		{
			this.updating = true;
			try
			{
				this.UpdateImages();
				this.UpdateVisible(this.GetNodeKind(node));
			}
			finally
			{
				this.updating = false;
			}
		}
		private void UpdateLexStyles()
		{
			this.lbStyles.BeginUpdate();
			try
			{
				this.lbStyles.Items.Clear();
				this.cbStyle.Items.Clear();
				this.cbreswordStyle.Items.Clear();
				for (int i = 0; i < this.Scheme.Styles.Count; i++)
				{
					if (this.Scheme.Styles[i].Name != string.Empty)
					{
						this.lbStyles.Items.Add(this.Scheme.Styles[i].Name);
						this.cbStyle.Items.Add(this.Scheme.Styles[i].Name);
						this.cbreswordStyle.Items.Add(this.Scheme.Styles[i].Name);
					}
					else
					{
						this.lbStyles.Items.Add("");
						this.cbStyle.Items.Add("");
						this.cbreswordStyle.Items.Add("");
					}
				}
			}
			finally
			{
				this.lbStyles.EndUpdate();
			}
		}
		private void ClearScheme()
		{
			this.Scheme.Clear();
			this.statesNode.Nodes.Clear();
			this.stylesNode.Nodes.Clear();
			this.Text = SyntaxBuilderConsts.SyntaxFormCaption;
			this.UpdateScheme();
		}
		private void LoadScheme()
		{
			if (this.openFileDialog.ShowDialog(this) == DialogResult.OK)
			{
				this.ClearScheme();
				this.lexer.Scheme.LoadFile(this.openFileDialog.FileName);
				this.Text = SyntaxBuilderConsts.SyntaxFormCaption + " " + this.openFileDialog.FileName;
				this.UpdateScheme();
			}
		}
		private void SaveScheme()
		{
			string empty = string.Empty;
			if (this.IsSchemeComplete(this.Scheme, out empty) || MessageBox.Show(string.Concat(new string[]
			{
				SyntaxBuilderConsts.InvalidScheme,
				": ",
				empty,
				"\n",
				SyntaxBuilderConsts.QueryInvalidScheme
			}), StringConsts.ErrorCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK)
			{
				if (this.saveFileDialog.ShowDialog(this) == DialogResult.OK)
				{
					this.lexer.Scheme.Version = SyntaxConsts.DefaultLexSchemeVersion;
					this.lexer.Scheme.SaveFile(this.saveFileDialog.FileName);
					this.Text = SyntaxBuilderConsts.SyntaxFormCaption + " " + this.saveFileDialog.FileName;
				}
			}
		}
		private void FillTree()
		{
			this.FillStyles();
			this.FillStates();
		}
		private void FillStyles()
		{
			this.stylesNode.Nodes.Clear();
			for (int i = 0; i < this.Scheme.Styles.Count; i++)
			{
				this.stylesNode.Nodes.Add(new TreeNode(this.Scheme.Styles[i].Name));
			}
		}
		private void FillStates()
		{
			this.statesNode.Nodes.Clear();
			for (int i = 0; i < this.Scheme.States.Count; i++)
			{
				this.statesNode.Nodes.Add(new TreeNode(this.Scheme.States[i].Name, 4, 4));
				TreeNode node = this.statesNode.Nodes[i];
				this.FillSyntaxBlocks(node, this.Scheme.States[i]);
			}
		}
		private void FillSyntaxBlocks(TreeNode node, LexState lexState)
		{
			if (node != null && lexState != null)
			{
				node.Nodes.Clear();
				for (int i = 0; i < lexState.SyntaxBlocks.Count; i++)
				{
					node.Nodes.Add(new TreeNode(lexState.SyntaxBlocks[i].Name));
					TreeNode node2 = node.Nodes[i];
					this.FillReswordSets(node2, lexState.SyntaxBlocks[i]);
				}
			}
		}
		private void FillReswordSets(TreeNode node, LexSyntaxBlock lexBlock)
		{
			if (node != null && lexBlock != null)
			{
				node.Nodes.Clear();
				for (int i = 0; i < lexBlock.ReswordSets.Count; i++)
				{
					node.Nodes.Add(new TreeNode(lexBlock.ReswordSets[i].Name));
				}
			}
		}
		private void FillControls()
		{
			this.UpdateGeneralPanel();
			this.UpdateLexStyles();
			this.UpdateLexStates();
			this.UpdateSyntaxBlocks(null);
			this.UpdateReswordSets(null);
			this.UpdateStylesControls();
			this.UpdateStatesControls();
			this.UpdateSyntaxBlocksControls();
			this.UpdateReswordSetsControls();
			this.UpdateStyleControls();
			this.UpdateStateControls();
			this.UpdateSyntaxBlockControls();
			this.UpdateReswordSetControls();
		}
		private void CheckSchemeNames(LexScheme scheme)
		{
			for (int i = 0; i < scheme.Styles.Count; i++)
			{
				scheme.Styles[i].Name = ((scheme.Styles[i].Name != string.Empty) ? scheme.Styles[i].Name : this.GetNewStyleName());
			}
			for (int i = 0; i < scheme.States.Count; i++)
			{
				LexState lexState = scheme.States[i];
				lexState.Name = ((lexState.Name != string.Empty) ? lexState.Name : this.GetNewStateName());
				for (int j = 0; j < lexState.SyntaxBlocks.Count; j++)
				{
					LexSyntaxBlock lexSyntaxBlock = lexState.SyntaxBlocks[j];
					lexSyntaxBlock.Name = ((lexSyntaxBlock.Name != string.Empty) ? lexSyntaxBlock.Name : this.GetNewSyntaxBlockName(lexState));
					for (int k = 0; k < lexSyntaxBlock.ReswordSets.Count; k++)
					{
						LexReswordSet lexReswordSet = lexSyntaxBlock.ReswordSets[k];
						lexReswordSet.Name = ((lexReswordSet.Name != string.Empty) ? lexReswordSet.Name : this.GetNewReswordSetName(lexSyntaxBlock));
					}
				}
			}
		}
		private void UpdateScheme()
		{
			this.CheckSchemeNames(this.Scheme);
			this.FillTree();
			this.FillControls();
			this.tvLexer.SelectedNode = this.rootNode;
			this.tvLexer.CollapseAll();
			this.rootNode.Expand();
		}
		private string GetNewStyleName()
		{
			string[] array = new string[this.Scheme.Styles.Count];
			for (int i = 0; i < this.Scheme.Styles.Count; i++)
			{
				array[i] = this.Scheme.Styles[i].Name;
			}
			int firstNumber = this.GetFirstNumber(array, SyntaxBuilderConsts.StyleText);
			return SyntaxBuilderConsts.StyleText + firstNumber.ToString();
		}
		private string GetNewStateName()
		{
			string[] array = new string[this.Scheme.States.Count];
			for (int i = 0; i < this.Scheme.States.Count; i++)
			{
				array[i] = this.Scheme.States[i].Name;
			}
			int firstNumber = this.GetFirstNumber(array, SyntaxBuilderConsts.StateText);
			return SyntaxBuilderConsts.StateText + firstNumber.ToString();
		}
		private string GetNewSyntaxBlockName(LexState lexState)
		{
			LexSyntaxBlocks syntaxBlocks = lexState.SyntaxBlocks;
			string[] array = new string[syntaxBlocks.Count];
			for (int i = 0; i < syntaxBlocks.Count; i++)
			{
				array[i] = syntaxBlocks[i].Name;
			}
			int firstNumber = this.GetFirstNumber(array, SyntaxBuilderConsts.BlockText);
			return SyntaxBuilderConsts.BlockText + firstNumber.ToString();
		}
		private string GetNewReswordSetName(LexSyntaxBlock lexBlock)
		{
			LexReswordSets reswordSets = lexBlock.ReswordSets;
			string[] array = new string[reswordSets.Count];
			for (int i = 0; i < reswordSets.Count; i++)
			{
				array[i] = reswordSets[i].Name;
			}
			int firstNumber = this.GetFirstNumber(array, SyntaxBuilderConsts.ReswordSetText);
			return SyntaxBuilderConsts.ReswordSetText + firstNumber.ToString();
		}
		private int GetFirstNumber(string[] list, string start)
		{
			List<int> list2 = new List<int>();
			for (int i = 0; i < list.Length; i++)
			{
				string text = list[i];
				if (text != null && text.StartsWith(start))
				{
					string s = text.Substring(start.Length);
					try
					{
						int item = int.Parse(s);
						list2.Add(item);
					}
					catch
					{
					}
				}
			}
			list2.Sort();
			int num = 0;
			for (int i = 0; i < list2.Count; i++)
			{
				if (list2[i] == num)
				{
					num++;
				}
			}
			return num;
		}
		private int GetFirstNumber(IList<int> list)
		{
			int num = 0;
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i] == num)
				{
					num++;
				}
			}
			return num;
		}
		private Panel GetCurrentPanel(DlgSyntaxBuilder.NodeKind kind)
		{
			Panel result;
			switch (kind)
			{
			case DlgSyntaxBuilder.NodeKind.nkStyles:
				result = this.pnStyles;
				break;
			case DlgSyntaxBuilder.NodeKind.nkStyle:
				result = this.pnStyle;
				break;
			case DlgSyntaxBuilder.NodeKind.nkStates:
				result = this.pnStates;
				break;
			case DlgSyntaxBuilder.NodeKind.nkState:
				result = this.pnState;
				break;
			case DlgSyntaxBuilder.NodeKind.nkSyntaxBlock:
				result = this.pnSyntaxBlock;
				break;
			case DlgSyntaxBuilder.NodeKind.nkGeneral:
				result = this.pnGeneral;
				break;
			case DlgSyntaxBuilder.NodeKind.nkreswordSet:
				result = this.pnReswordSet;
				break;
			default:
				result = this.pnGeneral;
				break;
			}
			return result;
		}
		private TreeNode GetParent(TreeNode node)
		{
			TreeNode treeNode = node;
			while (treeNode.Parent != null)
			{
				treeNode = treeNode.Parent;
			}
			return treeNode;
		}
		private TreeNode GetFolderNode()
		{
			TreeNode treeNode;
			TreeNode result;
			for (treeNode = this.tvLexer.SelectedNode; treeNode != null; treeNode = treeNode.Parent)
			{
				if (treeNode.ImageIndex == 0 || treeNode.ImageIndex == 1)
				{
					result = treeNode;
					return result;
				}
			}
			result = treeNode;
			return result;
		}
		private bool IsStyleUsed()
		{
			bool result = false;
			LexStyle lexStyle = this.GetLexStyle(this.lbStyles.SelectedIndex, this.Scheme);
			if (lexStyle != null)
			{
				for (int i = 0; i < this.Scheme.States.Count; i++)
				{
					for (int j = 0; j < this.Scheme.States[i].SyntaxBlocks.Count; j++)
					{
						if (lexStyle.Equals(this.Scheme.States[i].SyntaxBlocks[j].Style))
						{
							result = true;
							break;
						}
					}
				}
			}
			return result;
		}
		private bool IsStateUsed()
		{
			bool result = false;
			LexState lexState = this.GetLexState(this.lbStates.SelectedIndex, this.Scheme);
			if (lexState != null)
			{
				for (int i = 0; i < this.Scheme.States.Count; i++)
				{
					if (lexState != this.Scheme.States[i])
					{
						for (int j = 0; j < this.Scheme.States[i].SyntaxBlocks.Count; j++)
						{
							if (lexState.Equals(this.Scheme.States[i].SyntaxBlocks[j].LeaveState))
							{
								result = true;
								break;
							}
						}
					}
				}
			}
			return result;
		}
		private void MainForm_Load(object sender, EventArgs e)
		{
			base.Height = this.cDefaultHeight;
			base.Width = this.cDefaultWidth;
			TreeNode node = new TreeNode(this.sRemoveScroll);
			this.tvLexer.Nodes.Add(node);
			this.tvLexer.Nodes.Remove(node);
			this.tvLexer.SelectedNode = this.rootNode;
			this.rootNode.Expand();
			this.saveFileDialog.Filter = "xml files (*.xml)|*.xml";
			this.openFileDialog.Filter = "Scheme files (*.xml)|*.xml";
			this.LoadFromResource();
		}
		private void LoadFromResource()
		{
			this.Text = SyntaxBuilderConsts.DlgSyntaxBuilderCaption;
			if (this.tvLexer.Nodes.Count > 0)
			{
				this.tvLexer.Nodes[0].Text = SyntaxBuilderConsts.SyntaxSchemeEditorCaption;
				if (this.tvLexer.Nodes[0].Nodes.Count >= 3)
				{
					this.tvLexer.Nodes[0].Nodes[0].Text = SyntaxBuilderConsts.SyntaxSchemeGeneralCaption;
					this.tvLexer.Nodes[0].Nodes[1].Text = SyntaxBuilderConsts.SyntaxSchemeStylesCaption;
					this.tvLexer.Nodes[0].Nodes[2].Text = SyntaxBuilderConsts.SyntaxSchemeStatesCaption;
				}
				this.tpGeneral.Text = SyntaxBuilderConsts.GeneralCaption_SyntaxBuilderDlg;
				this.tpStyles.Text = SyntaxBuilderConsts.StylesCaption;
				this.tpStates.Text = SyntaxBuilderConsts.StatesCaption;
				this.laAuthor.Text = SyntaxBuilderConsts.AuthorCaption;
				this.laSchemeName.Text = SyntaxBuilderConsts.SchemeNameCaption;
				this.laDescription.Text = SyntaxBuilderConsts.DescriptionCaption_SyntaxBuilderDlg;
				this.laCopyright.Text = SyntaxBuilderConsts.CopyrightCaption;
				this.gbStyleProperties.Text = SyntaxBuilderConsts.StylePropertiesCaption;
				this.laStyleName.Text = SyntaxBuilderConsts.StyleNameCaption;
				this.laStyleDesc.Text = SyntaxBuilderConsts.StyleDescriptionCaption;
				this.laStyleForeColor.Text = SyntaxBuilderConsts.StyleForeColorCaption;
				this.laStyleBkColor.Text = SyntaxBuilderConsts.StyleBackColorCaption;
				this.gbFontStyles.Text = SyntaxBuilderConsts.FontStylesCaption;
				this.chbBold.Text = SyntaxBuilderConsts.BoldCaption_SyntaxBuilderDlg;
				this.chbItalic.Text = SyntaxBuilderConsts.ItalicCaption_SyntaxBuilderDlg;
				this.chbUnderline.Text = SyntaxBuilderConsts.UnderlineCaption_SyntaxBuilderDlg;
				this.chbStrikeout.Text = SyntaxBuilderConsts.StrikeOutCaption_SyntaxBuilderDlg;
				this.chbPlainText.Text = SyntaxBuilderConsts.PlainTextCaption;
				this.laSample.Text = SyntaxBuilderConsts.SampleCaption_SyntaxBuilderDlg;
				this.gbStateProperties.Text = SyntaxBuilderConsts.StatePropertiesCaption;
				this.laStateName.Text = SyntaxBuilderConsts.StateNameCaption;
				this.laStateDesc.Text = SyntaxBuilderConsts.StateDescriptionCaption;
				this.chbCaseSensitive.Text = SyntaxBuilderConsts.CaseSensitiveCaption;
				this.gbSyntaxBlockProperties.Text = SyntaxBuilderConsts.BlockPropertiesCaption;
				this.laBlockName.Text = SyntaxBuilderConsts.BlockNameCaption;
				this.laBlockDesc.Text = SyntaxBuilderConsts.BlockDescriptionCaption;
				this.laLeaveState.Text = SyntaxBuilderConsts.LeaveStateCaption;
				this.laStyle.Text = SyntaxBuilderConsts.BlockStyleCaption;
				this.laBlockExpr.Text = SyntaxBuilderConsts.BlockExpressionCaption;
				this.gbreswordsProperties.Text = SyntaxBuilderConsts.ReswordSetPropertiesCaption;
				this.lareswordSetName.Text = SyntaxBuilderConsts.ReswordSetNameCaption;
				this.lareswordStyle.Text = SyntaxBuilderConsts.ReswordStyleCaption;
				this.laBlockreswords.Text = SyntaxBuilderConsts.ReswordsCaption;
				this.btLoadScheme.Text = SyntaxBuilderConsts.LoadCaption;
				this.btSave.Text = SyntaxBuilderConsts.SaveCaption;
				this.btClear.Text = SyntaxBuilderConsts.ClearCaption;
				this.btOk.Text = SyntaxBuilderConsts.OKCaption_SyntaxBuilderDlg;
				this.btCancel.Text = SyntaxBuilderConsts.CancelCaption_SyntaxBuilderDlg;
			}
		}
		private void btSave_Click(object sender, EventArgs e)
		{
			this.SaveScheme();
		}
		private void btClear_Click(object sender, EventArgs e)
		{
			this.ClearScheme();
		}
		private void tvLexer_MouseDown(object sender, MouseEventArgs e)
		{
			if (e.Button == MouseButtons.Right)
			{
				TreeNode nodeAt = this.tvLexer.GetNodeAt(e.X, e.Y);
				if (nodeAt != null)
				{
					this.tvLexer.SelectedNode = nodeAt;
				}
			}
		}
		private void btLoadScheme_Click(object sender, EventArgs e)
		{
			this.LoadScheme();
		}
		private void tbAuthor_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.Scheme.Author = this.tbAuthor.Text;
			}
		}
		private void tbSchemeName_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.Scheme.Name = this.tbSchemeName.Text;
			}
		}
		private void tbDescription_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.Scheme.Desc = this.tbDescription.Text;
			}
		}
		private void tbCopyright_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.Scheme.Copyright = this.tbCopyright.Text;
			}
		}
		private void tbFileType_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.Scheme.FileType = this.tbFileType.Text;
			}
		}
		private void tbFileExt_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.Scheme.FileExtension = this.tbFileExt.Text;
			}
		}
		private void tvLexer_BeforeLabelEdit(object sender, NodeLabelEditEventArgs e)
		{
			int nodeLevel = this.GetNodeLevel(e.Node);
			e.CancelEdit = (nodeLevel <= 1);
		}
		private void tvLexer_AfterCollapse(object sender, TreeViewEventArgs e)
		{
			if (e.Node.Equals(this.stylesNode) || e.Node.Equals(this.statesNode))
			{
				e.Node.SelectedImageIndex = 1;
			}
		}
		private void tvLexer_AfterExpand(object sender, TreeViewEventArgs e)
		{
			if (e.Node.Equals(this.stylesNode) || e.Node.Equals(this.statesNode))
			{
				e.Node.SelectedImageIndex = 0;
			}
		}
		private void btOk_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.OK;
		}
		private void DoExit()
		{
			if (base.DialogResult == DialogResult.Cancel)
			{
				if (MessageBox.Show(SyntaxBuilderConsts.CancelText, SyntaxBuilderConsts.CancelCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
				{
					base.DialogResult = DialogResult.None;
				}
			}
			if (base.DialogResult == DialogResult.OK)
			{
				string empty = string.Empty;
				if (!this.IsSchemeComplete(this.Scheme, out empty) && MessageBox.Show(string.Concat(new string[]
				{
					SyntaxBuilderConsts.InvalidScheme,
					": ",
					empty,
					"\n",
					SyntaxBuilderConsts.QueryInvalidScheme
				}), StringConsts.ErrorCaption, MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK)
				{
					base.DialogResult = DialogResult.None;
				}
			}
		}
		private void btCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}
		private void tvLexer_AfterSelect(object sender, TreeViewEventArgs e)
		{
			if (this.updating)
			{
				this.UpdatePanelControls(this.GetNodeKind(e.Node));
			}
			else
			{
				this.UpdateTree(e.Node);
			}
		}
		private void DlgSyntaxBuilder_Closing(object sender, CancelEventArgs e)
		{
			this.DoExit();
		}
		private void UpdateSample()
		{
			LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
			if (lexStyle != null)
			{
				this.laSample.Font = new Font(this.laSample.Font.Name, this.laSample.Font.Size, lexStyle.FontStyle);
			}
			else
			{
				this.laSample.Font = new Font(this.laSample.Font.Name, this.laSample.Font.Size, FontStyle.Regular);
			}
			this.laSample.ForeColor = this.clbForeColor.SelectedColor;
			this.laSample.BackColor = this.clbBkColor.SelectedColor;
			int x = (this.pnSample.Width - this.laSample.Width) / 2;
			int y = (this.pnSample.Height - this.laSample.Height) / 2;
			this.laSample.Location = new Point(x, y);
		}
		private void UpdateStyleControls()
		{
			LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
			if (lexStyle != null)
			{
				this.tbStyleName.Text = lexStyle.Name;
				this.tbStyleDesc.Text = lexStyle.Desc;
				this.clbForeColor.SelectedColor = lexStyle.ForeColor;
				this.clbBkColor.SelectedColor = lexStyle.BackColor;
				this.chbBold.Checked = ((lexStyle.FontStyle & FontStyle.Bold) != FontStyle.Regular);
				this.chbItalic.Checked = ((lexStyle.FontStyle & FontStyle.Italic) != FontStyle.Regular);
				this.chbUnderline.Checked = ((lexStyle.FontStyle & FontStyle.Underline) != FontStyle.Regular);
				this.chbStrikeout.Checked = ((lexStyle.FontStyle & FontStyle.Strikeout) != FontStyle.Regular);
				this.chbPlainText.Checked = lexStyle.PlainText;
			}
			else
			{
				this.tbStyleName.Text = string.Empty;
				this.tbStyleDesc.Text = string.Empty;
				this.clbForeColor.SelectedColor = Color.Empty;
				this.clbBkColor.SelectedColor = Color.Empty;
				this.chbBold.Checked = false;
				this.chbItalic.Checked = false;
				this.chbUnderline.Checked = false;
				this.chbStrikeout.Checked = false;
				this.chbPlainText.Checked = false;
			}
			this.UpdateSample();
		}
		private void UpdateStateControls()
		{
			LexState lexState = this.GetLexState(this.tvLexer.SelectedNode, this.Scheme);
			if (lexState != null)
			{
				this.chbCaseSensitive.Checked = lexState.CaseSensitive;
				this.tbStateDesc.Text = lexState.Desc;
				this.tbStateName.Text = lexState.Name;
			}
			else
			{
				this.tbStateDesc.Text = string.Empty;
				this.tbStateName.Text = string.Empty;
				this.chbCaseSensitive.Checked = false;
			}
			this.UpdateSyntaxBlocks(lexState);
			this.UpdateSyntaxBlocksControls();
		}
		private void UpdateStatesControls()
		{
			bool flag = this.lbStates.SelectedIndex >= 0;
			this.btRemoveState.Enabled = (flag && !this.IsStateUsed());
			this.btMoveUpState.Enabled = (this.lbStates.SelectedIndex > 0);
			this.btMoveDownState.Enabled = (flag && this.lbStates.SelectedIndex < this.lbStates.Items.Count - 1);
		}
		private void UpdateSyntaxBlockControls()
		{
			LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
			this.cbStyle.SelectedIndex = this.GetStyleIndex(lexSyntaxBlock);
			this.cbLeaveState.SelectedIndex = this.GetLeaveStateIndex(lexSyntaxBlock);
			this.tbBlockName.Text = string.Empty;
			this.tbBlockDesc.Text = string.Empty;
			this.tbExpressions.Text = string.Empty;
			if (lexSyntaxBlock != null)
			{
				this.tbBlockName.Text = lexSyntaxBlock.Name;
				this.tbBlockDesc.Text = lexSyntaxBlock.Desc;
				foreach (string current in lexSyntaxBlock.Expressions)
				{
					this.tbExpressions.Text = ((this.tbExpressions.Text == string.Empty) ? current : (this.tbExpressions.Text + "\r\n" + current));
				}
			}
			this.UpdateReswordSets(lexSyntaxBlock);
		}
		private void UpdateSyntaxBlocksControls()
		{
			bool flag = this.lbSyntaxBlocks.SelectedIndex >= 0;
			this.btRemoveBlock.Enabled = flag;
			this.btMoveUpBlock.Enabled = (this.lbSyntaxBlocks.SelectedIndex > 0);
			this.btMoveDownBlock.Enabled = (flag && this.lbSyntaxBlocks.SelectedIndex < this.lbSyntaxBlocks.Items.Count - 1);
		}
		private void UpdateReswordSetControls()
		{
			LexReswordSet lexReswordSet = this.GetLexReswordSet(this.tvLexer.SelectedNode, this.Scheme);
			this.tbreswordSetName.Text = string.Empty;
			this.tbreswords.Text = string.Empty;
			if (lexReswordSet != null)
			{
				this.tbreswordSetName.Text = lexReswordSet.Name;
				this.cbreswordStyle.Enabled = (lexReswordSet.Reswords.Count > 0);
				this.cbreswordStyle.SelectedIndex = this.GetReswordStyleIndex(lexReswordSet);
				foreach (string current in lexReswordSet.Reswords)
				{
					this.tbreswords.Text = ((this.tbreswords.Text == string.Empty) ? current : (this.tbreswords.Text + "\r\n" + current));
				}
			}
		}
		private void UpdateReswordSetsControls()
		{
			bool flag = this.lbReswordSets.SelectedIndex >= 0;
			this.btRemoveReswordSet.Enabled = flag;
			this.btMoveUpReswordSet.Enabled = (this.lbReswordSets.SelectedIndex > 0);
			this.btMoveDownReswordSet.Enabled = (flag && this.lbReswordSets.SelectedIndex < this.lbReswordSets.Items.Count - 1);
		}
		private void UpdateStylesControls()
		{
			bool flag = this.lbStyles.SelectedIndex >= 0;
			this.btRemoveStyle.Enabled = (flag && !this.IsStyleUsed());
			this.btMoveUpStyle.Enabled = (this.lbStyles.SelectedIndex > 0);
			this.btMoveDownStyle.Enabled = (flag && this.lbStyles.SelectedIndex < this.lbStyles.Items.Count - 1);
		}
		private int GetReswordStyleIndex(LexReswordSet reswordSet)
		{
			int result;
			if (reswordSet != null && reswordSet.ReswordStyle != null)
			{
				for (int i = 0; i < this.cbreswordStyle.Items.Count; i++)
				{
					if (string.Compare(this.cbreswordStyle.Items[i].ToString(), reswordSet.ReswordStyle.Name) == 0)
					{
						result = i;
						return result;
					}
				}
			}
			result = -1;
			return result;
		}
		private int GetStyleIndex(LexSyntaxBlock block)
		{
			int result;
			if (block != null && block.Style != null)
			{
				for (int i = 0; i < this.cbStyle.Items.Count; i++)
				{
					if (string.Compare(this.cbStyle.Items[i].ToString(), block.Style.Name) == 0)
					{
						result = i;
						return result;
					}
				}
			}
			result = -1;
			return result;
		}
		private int GetLeaveStateIndex(LexSyntaxBlock block)
		{
			int result;
			if (block != null && block.LeaveState != null)
			{
				for (int i = 0; i < this.cbLeaveState.Items.Count; i++)
				{
					if (string.Compare(this.cbLeaveState.Items[i].ToString(), block.LeaveState.Name) == 0)
					{
						result = i;
						return result;
					}
				}
			}
			result = -1;
			return result;
		}
		private void lbStyles_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.UpdateStylesControls();
		}
		private void AddStyleClick(object sender, EventArgs e)
		{
			string newStyleName = this.GetNewStyleName();
			LexStyle lexStyle = this.Scheme.Styles.AddLexStyle();
			lexStyle.FontStyle = FontStyle.Regular;
			lexStyle.ForeColor = Color.Black;
			this.stylesNode.Nodes.Add(new TreeNode(newStyleName));
			this.stylesNode.Expand();
			lexStyle.Name = newStyleName;
			this.UpdateLexStyles();
			this.lbStyles.SelectedIndex = this.Scheme.Styles.Count - 1;
			this.UpdateStylesControls();
		}
		private void btAddStyle_Click(object sender, EventArgs e)
		{
			this.AddStyleClick(null, null);
		}
		private void SelectTreeViewNode(TreeNode node)
		{
			this.updating = true;
			try
			{
				this.tvLexer.SelectedNode = node;
				this.tvLexer.Focus();
			}
			finally
			{
				this.updating = false;
			}
		}
		private void RemoveStyleClick(object sender, EventArgs e)
		{
			int selectedIndex = this.lbStyles.SelectedIndex;
			this.Scheme.Styles.RemoveAt(this.lbStyles.SelectedIndex);
			TreeNode treeNode = (selectedIndex >= 0 && selectedIndex < this.stylesNode.Nodes.Count) ? this.stylesNode.Nodes[selectedIndex] : null;
			if (treeNode != null)
			{
				treeNode.Remove();
			}
			this.UpdateLexStyles();
			this.lbStyles.SelectedIndex = ((selectedIndex < this.lbStyles.Items.Count) ? selectedIndex : (selectedIndex - 1));
			this.UpdateStylesControls();
		}
		private void btRemoveStyle_Click(object sender, EventArgs e)
		{
			if (MessageBox.Show(string.Format(SyntaxBuilderConsts.RemoveText, "this style"), SyntaxBuilderConsts.CancelCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
			{
				this.RemoveStyleClick(null, null);
			}
		}
		private void UpdateStylePosition(int index)
		{
			LexStyle lexStyle = this.GetLexStyle(this.lbStyles.SelectedIndex, this.Scheme);
			if (lexStyle != null)
			{
				this.Scheme.Styles.Remove(lexStyle);
				this.Scheme.Styles.Insert(index, lexStyle);
				this.FillStyles();
				this.UpdateLexStyles();
				this.lbStyles.SelectedIndex = index;
				this.UpdateStylesControls();
			}
		}
		private void UpdateStatePosition(int index)
		{
			LexState lexState = this.GetLexState(this.lbStates.SelectedIndex, this.Scheme);
			if (lexState != null)
			{
				this.Scheme.States.Remove(lexState);
				this.Scheme.States.Insert(index, lexState);
				this.FillStates();
				this.UpdateLexStates();
				this.lbStates.SelectedIndex = index;
				this.UpdateStatesControls();
			}
		}
		private void UpdateSyntaxBlockPosition(int index)
		{
			LexState lexState = this.GetLexState(this.tvLexer.SelectedNode, this.Scheme);
			if (lexState != null)
			{
				LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.lbSyntaxBlocks.SelectedIndex, lexState);
				if (lexSyntaxBlock != null)
				{
					lexState.SyntaxBlocks.Remove(lexSyntaxBlock);
					lexState.SyntaxBlocks.Insert(index, lexSyntaxBlock);
					this.FillSyntaxBlocks(this.GetStateNode(this.tvLexer.SelectedNode), lexState);
					this.UpdateSyntaxBlocks(lexState);
					this.lbSyntaxBlocks.SelectedIndex = index;
					this.UpdateSyntaxBlocksControls();
				}
			}
		}
		private void UpdateReswordSetPosition(int index)
		{
			LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
			if (lexSyntaxBlock != null)
			{
				LexReswordSet lexReswordSet = this.GetLexReswordSet(this.lbReswordSets.SelectedIndex, lexSyntaxBlock);
				if (lexReswordSet != null)
				{
					lexSyntaxBlock.ReswordSets.Remove(lexReswordSet);
					lexSyntaxBlock.ReswordSets.Insert(index, lexReswordSet);
					this.FillReswordSets(this.GetSyntaxBlockNode(this.tvLexer.SelectedNode), lexSyntaxBlock);
					this.UpdateReswordSets(lexSyntaxBlock);
					this.lbReswordSets.SelectedIndex = index;
					this.UpdateReswordSetsControls();
				}
			}
		}
		private void btMoveUpStyle_Click(object sender, EventArgs e)
		{
			this.UpdateStylePosition(this.lbStyles.SelectedIndex - 1);
		}
		private void btMoveDownStyle_Click(object sender, EventArgs e)
		{
			this.UpdateStylePosition(this.lbStyles.SelectedIndex + 1);
		}
		private void AddStateClick(object sender, EventArgs e)
		{
			string newStateName = this.GetNewStateName();
			LexState lexState = this.Scheme.States.AddLexState();
			TreeNode treeNode = new TreeNode(newStateName);
			treeNode.ImageIndex = 4;
			treeNode.SelectedImageIndex = 4;
			this.statesNode.Nodes.Add(treeNode);
			this.statesNode.Expand();
			lexState.Name = newStateName;
			this.UpdateLexStates();
			this.lbStates.SelectedIndex = this.Scheme.States.Count - 1;
			this.UpdateStatesControls();
		}
		private void btAddState_Click(object sender, EventArgs e)
		{
			this.AddStateClick(null, null);
		}
		private void UpdateLexStates()
		{
			this.lbStates.BeginUpdate();
			try
			{
				this.lbStates.Items.Clear();
				this.cbLeaveState.Items.Clear();
				for (int i = 0; i < this.Scheme.States.Count; i++)
				{
					if (this.Scheme.States[i].Name != string.Empty)
					{
						this.lbStates.Items.Add(this.Scheme.States[i].Name);
						this.cbLeaveState.Items.Add(this.Scheme.States[i].Name);
					}
					else
					{
						this.lbStates.Items.Add("");
						this.cbLeaveState.Items.Add("");
					}
				}
			}
			finally
			{
				this.lbStates.EndUpdate();
			}
		}
		private void RemoveStateClick(object sender, EventArgs e)
		{
			int selectedIndex = this.lbStates.SelectedIndex;
			this.Scheme.States.RemoveAt(this.lbStates.SelectedIndex);
			TreeNode treeNode = (selectedIndex >= 0 && selectedIndex < this.statesNode.Nodes.Count) ? this.statesNode.Nodes[selectedIndex] : null;
			if (treeNode != null)
			{
				treeNode.Remove();
			}
			this.UpdateLexStates();
			this.lbStates.SelectedIndex = ((selectedIndex < this.lbStates.Items.Count) ? selectedIndex : (selectedIndex - 1));
		}
		private void btRemoveState_Click(object sender, EventArgs e)
		{
			if (MessageBox.Show(string.Format(SyntaxBuilderConsts.RemoveText, "this state"), SyntaxBuilderConsts.CancelCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
			{
				this.RemoveStateClick(null, null);
			}
		}
		private void lbStates_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.UpdateStatesControls();
		}
		private void btMoveUpState_Click(object sender, EventArgs e)
		{
			this.UpdateStatePosition(this.lbStates.SelectedIndex - 1);
		}
		private void btMoveDownState_Click(object sender, EventArgs e)
		{
			this.UpdateStatePosition(this.lbStates.SelectedIndex + 1);
		}
		private void UpdateSyntaxBlocks(LexState lexState)
		{
			this.lbSyntaxBlocks.BeginUpdate();
			try
			{
				this.lbSyntaxBlocks.Items.Clear();
				if (lexState != null)
				{
					for (int i = 0; i < lexState.SyntaxBlocks.Count; i++)
					{
						if (lexState.SyntaxBlocks[i].Name != string.Empty)
						{
							this.lbSyntaxBlocks.Items.Add(lexState.SyntaxBlocks[i].Name);
						}
						else
						{
							this.lbSyntaxBlocks.Items.Add("");
						}
					}
				}
			}
			finally
			{
				this.lbSyntaxBlocks.EndUpdate();
			}
		}
		private void AddBlockClick(object sender, EventArgs e)
		{
			LexState lexState = this.GetLexState(this.tvLexer.SelectedNode, this.Scheme);
			if (lexState != null)
			{
				string newSyntaxBlockName = this.GetNewSyntaxBlockName(lexState);
				LexSyntaxBlock lexSyntaxBlock = lexState.SyntaxBlocks.AddLexSyntaxBlock();
				lexSyntaxBlock.Name = newSyntaxBlockName;
				TreeNode stateNode = this.GetStateNode(this.tvLexer.SelectedNode);
				if (stateNode != null)
				{
					stateNode.Nodes.Add(new TreeNode(newSyntaxBlockName));
				}
				stateNode.Expand();
				this.UpdateSyntaxBlocks(lexState);
				this.lbSyntaxBlocks.SelectedIndex = lexState.SyntaxBlocks.Count - 1;
				this.UpdateSyntaxBlockControls();
			}
		}
		private void btAddBlock_Click(object sender, EventArgs e)
		{
			this.AddBlockClick(null, null);
		}
		private void RemoveBlockClick(object sender, EventArgs e)
		{
			int selectedIndex = this.lbSyntaxBlocks.SelectedIndex;
			LexState lexState = this.GetLexState(this.tvLexer.SelectedNode, this.Scheme);
			if (lexState != null)
			{
				lexState.SyntaxBlocks.RemoveAt(this.lbSyntaxBlocks.SelectedIndex);
				TreeNode treeNode = (selectedIndex >= 0 && selectedIndex < this.tvLexer.SelectedNode.Nodes.Count) ? this.tvLexer.SelectedNode.Nodes[selectedIndex] : null;
				if (treeNode != null)
				{
					treeNode.Remove();
				}
				this.UpdateSyntaxBlocks(lexState);
				this.lbSyntaxBlocks.SelectedIndex = ((selectedIndex < this.lbSyntaxBlocks.Items.Count) ? selectedIndex : (selectedIndex - 1));
			}
		}
		private void btRemoveBlock_Click(object sender, EventArgs e)
		{
			if (MessageBox.Show(string.Format(SyntaxBuilderConsts.RemoveText, "this block"), SyntaxBuilderConsts.CancelCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
			{
				this.RemoveBlockClick(null, null);
			}
		}
		private void btMoveUpBlock_Click(object sender, EventArgs e)
		{
			this.UpdateSyntaxBlockPosition(this.lbSyntaxBlocks.SelectedIndex - 1);
		}
		private void btMoveDownBlock_Click(object sender, EventArgs e)
		{
			this.UpdateSyntaxBlockPosition(this.lbSyntaxBlocks.SelectedIndex + 1);
		}
		private void UpdateReswordSets(LexSyntaxBlock lexBlock)
		{
			this.lbReswordSets.BeginUpdate();
			try
			{
				this.lbReswordSets.Items.Clear();
				if (lexBlock != null)
				{
					for (int i = 0; i < lexBlock.ReswordSets.Count; i++)
					{
						if (lexBlock.ReswordSets[i].Name != string.Empty)
						{
							this.lbReswordSets.Items.Add(lexBlock.ReswordSets[i].Name);
						}
						else
						{
							this.lbReswordSets.Items.Add("");
						}
					}
				}
			}
			finally
			{
				this.lbReswordSets.EndUpdate();
			}
		}
		private void AddReswordSetClick(object sender, EventArgs e)
		{
			LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
			if (lexSyntaxBlock != null)
			{
				string newReswordSetName = this.GetNewReswordSetName(lexSyntaxBlock);
				LexReswordSet lexReswordSet = lexSyntaxBlock.ReswordSets.AddLexReswordSet();
				lexReswordSet.Name = newReswordSetName;
				TreeNode syntaxBlockNode = this.GetSyntaxBlockNode(this.tvLexer.SelectedNode);
				if (syntaxBlockNode != null)
				{
					syntaxBlockNode.Nodes.Add(new TreeNode(newReswordSetName));
				}
				syntaxBlockNode.Expand();
				this.UpdateReswordSets(lexSyntaxBlock);
				this.lbReswordSets.SelectedIndex = lexSyntaxBlock.ReswordSets.Count - 1;
			}
		}
		private void btAddReswordSet_Click(object sender, EventArgs e)
		{
			this.AddReswordSetClick(null, null);
		}
		private void RemoveReswordSetClick(object sender, EventArgs e)
		{
			int selectedIndex = this.lbReswordSets.SelectedIndex;
			LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
			if (lexSyntaxBlock != null)
			{
				lexSyntaxBlock.ReswordSets.RemoveAt(this.lbReswordSets.SelectedIndex);
				TreeNode treeNode = (selectedIndex >= 0 && selectedIndex < this.tvLexer.SelectedNode.Nodes.Count) ? this.tvLexer.SelectedNode.Nodes[selectedIndex] : null;
				if (treeNode != null)
				{
					treeNode.Remove();
				}
				this.UpdateReswordSets(lexSyntaxBlock);
				this.lbReswordSets.SelectedIndex = ((selectedIndex < this.lbReswordSets.Items.Count) ? selectedIndex : (selectedIndex - 1));
			}
		}
		private void btRemoveReswordSet_Click(object sender, EventArgs e)
		{
			if (MessageBox.Show(string.Format(SyntaxBuilderConsts.RemoveText, "this resword set"), SyntaxBuilderConsts.CancelCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
			{
				this.RemoveReswordSetClick(null, null);
			}
		}
		private void btMoveUpReswordSet_Click(object sender, EventArgs e)
		{
			this.UpdateReswordSetPosition(this.lbReswordSets.SelectedIndex - 1);
		}
		private void btMoveDownReswordSet_Click(object sender, EventArgs e)
		{
			this.UpdateReswordSetPosition(this.lbReswordSets.SelectedIndex + 1);
		}
		private void lbSyntaxBlocks_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.UpdateSyntaxBlocksControls();
		}
		private void lbReswordSets_SelectedIndexChanged(object sender, EventArgs e)
		{
			this.UpdateReswordSetsControls();
		}
		private void tbStyleName_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
				if (lexStyle != null)
				{
					TreeNode styleNode = this.GetStyleNode(this.tvLexer.SelectedNode);
					if (styleNode != null)
					{
						styleNode.Text = this.tbStyleName.Text;
					}
					lexStyle.Name = this.tbStyleName.Text;
					this.UpdateLexStyles();
				}
			}
		}
		private void tbStyleDesc_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
				if (lexStyle != null)
				{
					lexStyle.Desc = this.tbStyleDesc.Text;
				}
			}
		}
		private void clbForeColor_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
				if (lexStyle != null)
				{
					lexStyle.ForeColor = this.clbForeColor.SelectedColor;
				}
				this.UpdateSample();
			}
		}
		private void clbBkColor_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
				if (lexStyle != null)
				{
					lexStyle.BackColor = this.clbBkColor.SelectedColor;
				}
				this.UpdateSample();
			}
		}
		private void chbBold_CheckedChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.UpdateFontStyle();
			}
		}
		private void chbItalic_CheckedChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.UpdateFontStyle();
			}
		}
		private void chbStrikeout_CheckedChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.UpdateFontStyle();
			}
		}
		private void chbUnderline_CheckedChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.UpdateFontStyle();
			}
		}
		private void chbPlainText_CheckedChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
				if (lexStyle != null)
				{
					lexStyle.PlainText = this.chbPlainText.Checked;
				}
			}
		}
		private void UpdateFontStyle()
		{
			DlgSyntaxBuilder.NodeKind nodeKind = this.GetNodeKind(this.tvLexer.SelectedNode);
			if (nodeKind == DlgSyntaxBuilder.NodeKind.nkStyle || nodeKind == DlgSyntaxBuilder.NodeKind.nkStyles)
			{
				this.updating = true;
				try
				{
					LexStyle lexStyle = this.GetLexStyle(this.tvLexer.SelectedNode, this.Scheme);
					if (lexStyle != null)
					{
						lexStyle.FontStyle = FontStyle.Regular;
						if (this.chbBold.Checked)
						{
							lexStyle.FontStyle |= FontStyle.Bold;
						}
						if (this.chbItalic.Checked)
						{
							lexStyle.FontStyle |= FontStyle.Italic;
						}
						if (this.chbUnderline.Checked)
						{
							lexStyle.FontStyle |= FontStyle.Underline;
						}
						if (this.chbStrikeout.Checked)
						{
							lexStyle.FontStyle |= FontStyle.Strikeout;
						}
					}
				}
				finally
				{
					this.updating = false;
				}
				this.UpdateSample();
			}
		}
		private void tbStateName_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexState lexState = this.GetLexState(this.tvLexer.SelectedNode, this.Scheme);
				if (lexState != null)
				{
					TreeNode stateNode = this.GetStateNode(this.tvLexer.SelectedNode);
					if (stateNode != null)
					{
						stateNode.Text = this.tbStateName.Text;
					}
					lexState.Name = this.tbStateName.Text;
					this.UpdateLexStates();
				}
			}
		}
		private void tbStateDesc_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexState lexState = this.GetLexState(this.tvLexer.SelectedNode, this.Scheme);
				if (lexState != null)
				{
					lexState.Desc = this.tbStateDesc.Text;
				}
			}
		}
		private void chbCaseSensitive_CheckedChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexState lexState = this.GetLexState(this.tvLexer.SelectedNode, this.Scheme);
				if (lexState != null)
				{
					lexState.CaseSensitive = this.chbCaseSensitive.Checked;
				}
			}
		}
		private void tbBlockName_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
				if (lexSyntaxBlock != null)
				{
					this.GetSyntaxBlockNode(this.tvLexer.SelectedNode).Text = this.tbBlockName.Text;
					lexSyntaxBlock.Name = this.tbBlockName.Text;
				}
			}
		}
		private void tbBlockDesc_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
				if (lexSyntaxBlock != null)
				{
					lexSyntaxBlock.Desc = this.tbBlockDesc.Text;
				}
			}
		}
		private void cbLeaveState_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
				if (lexSyntaxBlock != null && this.cbLeaveState.SelectedIndex >= 0)
				{
					lexSyntaxBlock.LeaveState = this.Scheme.States[this.cbLeaveState.SelectedIndex];
				}
			}
		}
		private void cbStyle_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
				if (lexSyntaxBlock != null && this.cbStyle.SelectedIndex >= 0)
				{
					lexSyntaxBlock.Style = this.Scheme.Styles[this.cbStyle.SelectedIndex];
				}
			}
		}
		private void UpdateBlockExpressions()
		{
			LexSyntaxBlock lexSyntaxBlock = this.GetLexSyntaxBlock(this.tvLexer.SelectedNode, this.Scheme);
			if (lexSyntaxBlock != null)
			{
				lexSyntaxBlock.Expressions = new string[0];
				string[] lines = this.tbExpressions.Lines;
				for (int i = 0; i < lines.Length; i++)
				{
					string text = lines[i];
					string text2 = text.Trim();
					if (text2 != string.Empty)
					{
						lexSyntaxBlock.AddExpression(text2);
					}
				}
			}
		}
		private void tbExpressions_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.UpdateBlockExpressions();
			}
		}
		private void tbreswordSetName_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexReswordSet lexReswordSet = this.GetLexReswordSet(this.tvLexer.SelectedNode, this.Scheme);
				if (lexReswordSet != null)
				{
					this.tvLexer.SelectedNode.Text = this.tbreswordSetName.Text;
					lexReswordSet.Name = this.tbreswordSetName.Text;
				}
			}
		}
		private void cbreswordStyle_SelectedIndexChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				LexReswordSet lexReswordSet = this.GetLexReswordSet(this.tvLexer.SelectedNode, this.Scheme);
				if (lexReswordSet != null && this.cbreswordStyle.SelectedIndex >= 0)
				{
					lexReswordSet.ReswordStyle = this.Scheme.Styles[this.cbreswordStyle.SelectedIndex];
				}
			}
		}
		private void UpdateReswords()
		{
			LexReswordSet lexReswordSet = this.GetLexReswordSet(this.tvLexer.SelectedNode, this.Scheme);
			if (lexReswordSet != null)
			{
				lexReswordSet.Reswords = new string[0];
				string[] lines = this.tbreswords.Lines;
				for (int i = 0; i < lines.Length; i++)
				{
					string text = lines[i];
					string text2 = text.Trim();
					if (text2 != string.Empty && !lexReswordSet.FindResword(text2))
					{
						lexReswordSet.AddResword(text2);
					}
				}
			}
			this.cbreswordStyle.Enabled = (lexReswordSet != null && lexReswordSet.Reswords.Count > 0);
		}
		private void tbreswords_TextChanged(object sender, EventArgs e)
		{
			if (!this.updating)
			{
				this.UpdateReswords();
			}
		}
		protected int GetSyntaxBlockIndex(TreeNode node, LexScheme scheme)
		{
			return (this.GetLexState(node.Parent, scheme) != null) ? node.Index : -1;
		}
		protected int GetReswordSetIndex(TreeNode node, LexScheme scheme)
		{
			return (this.GetLexSyntaxBlock(node.Parent, scheme) != null) ? node.Index : -1;
		}
		protected int GetLexStateIndex(TreeNode node, LexScheme scheme)
		{
			int result;
			switch (this.GetNodeKind(node))
			{
			case DlgSyntaxBuilder.NodeKind.nkStates:
				if (node.Nodes.Count > 0 && scheme.States.Count > 0)
				{
					result = 0;
				}
				else
				{
					result = -1;
				}
				break;
			case DlgSyntaxBuilder.NodeKind.nkState:
				result = node.Index;
				break;
			default:
				result = -1;
				break;
			}
			return result;
		}
		protected int GetLexStyleIndex(TreeNode node, LexScheme scheme)
		{
			int result;
			switch (this.GetNodeKind(node))
			{
			case DlgSyntaxBuilder.NodeKind.nkStyles:
				if (node.Nodes.Count > 0 && scheme.Styles.Count > 0)
				{
					result = 0;
				}
				else
				{
					result = -1;
				}
				break;
			case DlgSyntaxBuilder.NodeKind.nkStyle:
				result = node.Index;
				break;
			default:
				result = -1;
				break;
			}
			return result;
		}
		protected LexStyle GetLexStyle(TreeNode node, LexScheme scheme)
		{
			LexStyle result;
			switch (this.GetNodeKind(node))
			{
			case DlgSyntaxBuilder.NodeKind.nkStyles:
				if (node.Nodes.Count > 0 && scheme.Styles.Count > 0)
				{
					result = scheme.Styles[0];
				}
				else
				{
					result = null;
				}
				break;
			case DlgSyntaxBuilder.NodeKind.nkStyle:
				result = scheme.Styles[node.Index];
				break;
			default:
				result = null;
				break;
			}
			return result;
		}
		protected LexStyle GetLexStyle(int index, LexScheme scheme)
		{
			return (index >= 0 && index < scheme.Styles.Count) ? scheme.Styles[index] : null;
		}
		protected LexState GetLexState(TreeNode node, LexScheme scheme)
		{
			LexState result;
			switch (this.GetNodeKind(node))
			{
			case DlgSyntaxBuilder.NodeKind.nkStates:
				if (this.statesNode.Nodes.Count > 0 && scheme.States.Count > 0)
				{
					result = scheme.States[0];
					return result;
				}
				result = null;
				return result;
			case DlgSyntaxBuilder.NodeKind.nkState:
				result = scheme.States[node.Index];
				return result;
			case DlgSyntaxBuilder.NodeKind.nkSyntaxBlock:
				result = scheme.States[node.Parent.Index];
				return result;
			case DlgSyntaxBuilder.NodeKind.nkreswordSet:
				result = scheme.States[node.Parent.Parent.Index];
				return result;
			}
			result = null;
			return result;
		}
		protected LexState GetLexState(int index, LexScheme scheme)
		{
			return (index >= 0 && index < scheme.States.Count) ? scheme.States[index] : null;
		}
		protected LexSyntaxBlock GetLexSyntaxBlock(int index, LexState lexState)
		{
			LexSyntaxBlock result;
			if (lexState == null)
			{
				result = null;
			}
			else
			{
				result = ((index >= 0 && index < lexState.SyntaxBlocks.Count) ? lexState.SyntaxBlocks[index] : null);
			}
			return result;
		}
		protected LexReswordSet GetLexReswordSet(int index, LexSyntaxBlock lexBlock)
		{
			LexReswordSet result;
			if (lexBlock == null)
			{
				result = null;
			}
			else
			{
				result = ((index >= 0 && index < lexBlock.ReswordSets.Count) ? lexBlock.ReswordSets[index] : null);
			}
			return result;
		}
	}
}
